@angular-eslint/bundled-angular-compiler 14.0.0-alpha.2 → 14.0.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/CHANGELOG.md +4 -0
- package/dist/index.js +495 -391
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular
|
|
2
|
+
* @license Angular v14.0.0
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -211,7 +211,7 @@ class CssSelector {
|
|
|
211
211
|
let inNot = false;
|
|
212
212
|
_SELECTOR_REGEXP.lastIndex = 0;
|
|
213
213
|
while (match = _SELECTOR_REGEXP.exec(selector)) {
|
|
214
|
-
if (match[1 /* NOT */]) {
|
|
214
|
+
if (match[1 /* SelectorRegexp.NOT */]) {
|
|
215
215
|
if (inNot) {
|
|
216
216
|
throw new Error('Nesting :not in a selector is not allowed');
|
|
217
217
|
}
|
|
@@ -219,31 +219,31 @@ class CssSelector {
|
|
|
219
219
|
current = new CssSelector();
|
|
220
220
|
cssSelector.notSelectors.push(current);
|
|
221
221
|
}
|
|
222
|
-
const tag = match[2 /* TAG */];
|
|
222
|
+
const tag = match[2 /* SelectorRegexp.TAG */];
|
|
223
223
|
if (tag) {
|
|
224
|
-
const prefix = match[3 /* PREFIX */];
|
|
224
|
+
const prefix = match[3 /* SelectorRegexp.PREFIX */];
|
|
225
225
|
if (prefix === '#') {
|
|
226
226
|
// #hash
|
|
227
|
-
current.addAttribute('id', tag.
|
|
227
|
+
current.addAttribute('id', tag.slice(1));
|
|
228
228
|
}
|
|
229
229
|
else if (prefix === '.') {
|
|
230
230
|
// Class
|
|
231
|
-
current.addClassName(tag.
|
|
231
|
+
current.addClassName(tag.slice(1));
|
|
232
232
|
}
|
|
233
233
|
else {
|
|
234
234
|
// Element
|
|
235
235
|
current.setElement(tag);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
const attribute = match[4 /* ATTRIBUTE */];
|
|
238
|
+
const attribute = match[4 /* SelectorRegexp.ATTRIBUTE */];
|
|
239
239
|
if (attribute) {
|
|
240
|
-
current.addAttribute(current.unescapeAttribute(attribute), match[6 /* ATTRIBUTE_VALUE */]);
|
|
240
|
+
current.addAttribute(current.unescapeAttribute(attribute), match[6 /* SelectorRegexp.ATTRIBUTE_VALUE */]);
|
|
241
241
|
}
|
|
242
|
-
if (match[7 /* NOT_END */]) {
|
|
242
|
+
if (match[7 /* SelectorRegexp.NOT_END */]) {
|
|
243
243
|
inNot = false;
|
|
244
244
|
current = cssSelector;
|
|
245
245
|
}
|
|
246
|
-
if (match[8 /* SEPARATOR */]) {
|
|
246
|
+
if (match[8 /* SelectorRegexp.SEPARATOR */]) {
|
|
247
247
|
if (inNot) {
|
|
248
248
|
throw new Error('Multiple selectors in :not are not supported');
|
|
249
249
|
}
|
|
@@ -611,26 +611,26 @@ var MissingTranslationStrategy;
|
|
|
611
611
|
})(MissingTranslationStrategy || (MissingTranslationStrategy = {}));
|
|
612
612
|
function parserSelectorToSimpleSelector(selector) {
|
|
613
613
|
const classes = selector.classNames && selector.classNames.length ?
|
|
614
|
-
[8 /* CLASS */, ...selector.classNames] :
|
|
614
|
+
[8 /* SelectorFlags.CLASS */, ...selector.classNames] :
|
|
615
615
|
[];
|
|
616
616
|
const elementName = selector.element && selector.element !== '*' ? selector.element : '';
|
|
617
617
|
return [elementName, ...selector.attrs, ...classes];
|
|
618
618
|
}
|
|
619
619
|
function parserSelectorToNegativeSelector(selector) {
|
|
620
620
|
const classes = selector.classNames && selector.classNames.length ?
|
|
621
|
-
[8 /* CLASS */, ...selector.classNames] :
|
|
621
|
+
[8 /* SelectorFlags.CLASS */, ...selector.classNames] :
|
|
622
622
|
[];
|
|
623
623
|
if (selector.element) {
|
|
624
624
|
return [
|
|
625
|
-
1 /* NOT */ | 4 /* ELEMENT */, selector.element, ...selector.attrs, ...classes
|
|
625
|
+
1 /* SelectorFlags.NOT */ | 4 /* SelectorFlags.ELEMENT */, selector.element, ...selector.attrs, ...classes
|
|
626
626
|
];
|
|
627
627
|
}
|
|
628
628
|
else if (selector.attrs.length) {
|
|
629
|
-
return [1 /* NOT */ | 2 /* ATTRIBUTE */, ...selector.attrs, ...classes];
|
|
629
|
+
return [1 /* SelectorFlags.NOT */ | 2 /* SelectorFlags.ATTRIBUTE */, ...selector.attrs, ...classes];
|
|
630
630
|
}
|
|
631
631
|
else {
|
|
632
632
|
return selector.classNames && selector.classNames.length ?
|
|
633
|
-
[1 /* NOT */ | 8 /* CLASS */, ...selector.classNames] :
|
|
633
|
+
[1 /* SelectorFlags.NOT */ | 8 /* SelectorFlags.CLASS */, ...selector.classNames] :
|
|
634
634
|
[];
|
|
635
635
|
}
|
|
636
636
|
}
|
|
@@ -752,13 +752,13 @@ class Version {
|
|
|
752
752
|
this.patch = splits.slice(2).join('.');
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
755
|
+
// Check `global` first, because in Node tests both `global` and `window` may be defined and our
|
|
756
|
+
// `_global` variable should point to the NodeJS `global` in that case. Note: Typeof/Instanceof
|
|
757
|
+
// checks are considered side-effects in Terser. We explicitly mark this as side-effect free:
|
|
758
|
+
// https://github.com/terser/terser/issues/250.
|
|
759
|
+
const _global = ( /* @__PURE__ */(() => (typeof global !== 'undefined' && global) || (typeof window !== 'undefined' && window) ||
|
|
760
|
+
(typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
|
|
761
|
+
self instanceof WorkerGlobalScope && self))());
|
|
762
762
|
function newArray(size, value) {
|
|
763
763
|
const list = [];
|
|
764
764
|
for (let i = 0; i < size; i++) {
|
|
@@ -2796,6 +2796,7 @@ Identifiers.stylePropInterpolate7 = { name: 'ɵɵstylePropInterpolate7', moduleN
|
|
|
2796
2796
|
Identifiers.stylePropInterpolate8 = { name: 'ɵɵstylePropInterpolate8', moduleName: CORE };
|
|
2797
2797
|
Identifiers.stylePropInterpolateV = { name: 'ɵɵstylePropInterpolateV', moduleName: CORE };
|
|
2798
2798
|
Identifiers.nextContext = { name: 'ɵɵnextContext', moduleName: CORE };
|
|
2799
|
+
Identifiers.resetView = { name: 'ɵɵresetView', moduleName: CORE };
|
|
2799
2800
|
Identifiers.templateCreate = { name: 'ɵɵtemplate', moduleName: CORE };
|
|
2800
2801
|
Identifiers.text = { name: 'ɵɵtext', moduleName: CORE };
|
|
2801
2802
|
Identifiers.enableBindings = { name: 'ɵɵenableBindings', moduleName: CORE };
|
|
@@ -2906,6 +2907,7 @@ Identifiers.ModuleWithProviders = {
|
|
|
2906
2907
|
Identifiers.defineNgModule = { name: 'ɵɵdefineNgModule', moduleName: CORE };
|
|
2907
2908
|
Identifiers.declareNgModule = { name: 'ɵɵngDeclareNgModule', moduleName: CORE };
|
|
2908
2909
|
Identifiers.setNgModuleScope = { name: 'ɵɵsetNgModuleScope', moduleName: CORE };
|
|
2910
|
+
Identifiers.registerNgModuleType = { name: 'ɵɵregisterNgModuleType', moduleName: CORE };
|
|
2909
2911
|
Identifiers.PipeDeclaration = { name: 'ɵɵPipeDeclaration', moduleName: CORE };
|
|
2910
2912
|
Identifiers.definePipe = { name: 'ɵɵdefinePipe', moduleName: CORE };
|
|
2911
2913
|
Identifiers.declarePipe = { name: 'ɵɵngDeclarePipe', moduleName: CORE };
|
|
@@ -2918,6 +2920,7 @@ Identifiers.contentQuery = { name: 'ɵɵcontentQuery', moduleName: CORE };
|
|
|
2918
2920
|
Identifiers.NgOnChangesFeature = { name: 'ɵɵNgOnChangesFeature', moduleName: CORE };
|
|
2919
2921
|
Identifiers.InheritDefinitionFeature = { name: 'ɵɵInheritDefinitionFeature', moduleName: CORE };
|
|
2920
2922
|
Identifiers.CopyDefinitionFeature = { name: 'ɵɵCopyDefinitionFeature', moduleName: CORE };
|
|
2923
|
+
Identifiers.StandaloneFeature = { name: 'ɵɵStandaloneFeature', moduleName: CORE };
|
|
2921
2924
|
Identifiers.ProvidersFeature = { name: 'ɵɵProvidersFeature', moduleName: CORE };
|
|
2922
2925
|
Identifiers.listener = { name: 'ɵɵlistener', moduleName: CORE };
|
|
2923
2926
|
Identifiers.getInheritedFactory = {
|
|
@@ -3659,10 +3662,10 @@ function createMayBeForwardRefExpression(expression, forwardRef) {
|
|
|
3659
3662
|
*/
|
|
3660
3663
|
function convertFromMaybeForwardRefExpression({ expression, forwardRef }) {
|
|
3661
3664
|
switch (forwardRef) {
|
|
3662
|
-
case 0 /* None */:
|
|
3663
|
-
case 1 /* Wrapped */:
|
|
3665
|
+
case 0 /* ForwardRefHandling.None */:
|
|
3666
|
+
case 1 /* ForwardRefHandling.Wrapped */:
|
|
3664
3667
|
return expression;
|
|
3665
|
-
case 2 /* Unwrapped */:
|
|
3668
|
+
case 2 /* ForwardRefHandling.Unwrapped */:
|
|
3666
3669
|
return generateForwardRef(expression);
|
|
3667
3670
|
}
|
|
3668
3671
|
}
|
|
@@ -3786,14 +3789,14 @@ function compileInjectDependency(dep, target, index) {
|
|
|
3786
3789
|
}
|
|
3787
3790
|
else if (dep.attributeNameType === null) {
|
|
3788
3791
|
// Build up the injection flags according to the metadata.
|
|
3789
|
-
const flags = 0 /* Default */ | (dep.self ? 2 /* Self */ : 0) |
|
|
3790
|
-
(dep.skipSelf ? 4 /* SkipSelf */ : 0) | (dep.host ? 1 /* Host */ : 0) |
|
|
3791
|
-
(dep.optional ? 8 /* Optional */ : 0) |
|
|
3792
|
-
(target === exports.FactoryTarget.Pipe ? 16 /* ForPipe */ : 0);
|
|
3792
|
+
const flags = 0 /* InjectFlags.Default */ | (dep.self ? 2 /* InjectFlags.Self */ : 0) |
|
|
3793
|
+
(dep.skipSelf ? 4 /* InjectFlags.SkipSelf */ : 0) | (dep.host ? 1 /* InjectFlags.Host */ : 0) |
|
|
3794
|
+
(dep.optional ? 8 /* InjectFlags.Optional */ : 0) |
|
|
3795
|
+
(target === exports.FactoryTarget.Pipe ? 16 /* InjectFlags.ForPipe */ : 0);
|
|
3793
3796
|
// If this dependency is optional or otherwise has non-default flags, then additional
|
|
3794
3797
|
// parameters describing how to inject the dependency must be passed to the inject function
|
|
3795
3798
|
// that's being used.
|
|
3796
|
-
let flagsParam = (flags !== 0 /* Default */ || dep.optional) ? literal(flags) : null;
|
|
3799
|
+
let flagsParam = (flags !== 0 /* InjectFlags.Default */ || dep.optional) ? literal(flags) : null;
|
|
3797
3800
|
// Build up the arguments to the injectFn call.
|
|
3798
3801
|
const injectArgs = [dep.token];
|
|
3799
3802
|
if (flagsParam) {
|
|
@@ -3964,8 +3967,8 @@ class BoundEvent {
|
|
|
3964
3967
|
this.keySpan = keySpan;
|
|
3965
3968
|
}
|
|
3966
3969
|
static fromParsedEvent(event) {
|
|
3967
|
-
const target = event.type === 0 /* Regular */ ? event.targetOrPhase : null;
|
|
3968
|
-
const phase = event.type === 1 /* Animation */ ? event.targetOrPhase : null;
|
|
3970
|
+
const target = event.type === 0 /* ParsedEventType.Regular */ ? event.targetOrPhase : null;
|
|
3971
|
+
const phase = event.type === 1 /* ParsedEventType.Animation */ ? event.targetOrPhase : null;
|
|
3969
3972
|
if (event.keySpan === undefined) {
|
|
3970
3973
|
throw new Error(`Unexpected state: keySpan must be defined for bound event but was not for ${event.name}: ${event.sourceSpan}`);
|
|
3971
3974
|
}
|
|
@@ -4706,7 +4709,7 @@ function assembleBoundTextPlaceholders(meta, bindingStartIndex = 0, contextId =
|
|
|
4706
4709
|
* @param useCamelCase whether to camelCase the placeholder name when formatting.
|
|
4707
4710
|
* @returns A new map of formatted placeholder names to expressions.
|
|
4708
4711
|
*/
|
|
4709
|
-
function
|
|
4712
|
+
function formatI18nPlaceholderNamesInMap(params = {}, useCamelCase) {
|
|
4710
4713
|
const _params = {};
|
|
4711
4714
|
if (params && Object.keys(params).length) {
|
|
4712
4715
|
Object.keys(params).forEach(key => _params[formatI18nPlaceholderName(key, useCamelCase)] = params[key]);
|
|
@@ -4789,6 +4792,12 @@ const IMPLICIT_REFERENCE = '$implicit';
|
|
|
4789
4792
|
const NON_BINDABLE_ATTR = 'ngNonBindable';
|
|
4790
4793
|
/** Name for the variable keeping track of the context returned by `ɵɵrestoreView`. */
|
|
4791
4794
|
const RESTORED_VIEW_CONTEXT_NAME = 'restoredCtx';
|
|
4795
|
+
/**
|
|
4796
|
+
* Maximum length of a single instruction chain. Because our output AST uses recursion, we're
|
|
4797
|
+
* limited in how many expressions we can nest before we reach the call stack limit. This
|
|
4798
|
+
* length is set very conservatively in order to reduce the chance of problems.
|
|
4799
|
+
*/
|
|
4800
|
+
const MAX_CHAIN_LENGTH = 500;
|
|
4792
4801
|
/** Instructions that support chaining. */
|
|
4793
4802
|
const CHAINABLE_INSTRUCTIONS = new Set([
|
|
4794
4803
|
Identifiers.element,
|
|
@@ -4934,10 +4943,10 @@ function getQueryPredicate(query, constantPool) {
|
|
|
4934
4943
|
else {
|
|
4935
4944
|
// The original predicate may have been wrapped in a `forwardRef()` call.
|
|
4936
4945
|
switch (query.predicate.forwardRef) {
|
|
4937
|
-
case 0 /* None */:
|
|
4938
|
-
case 2 /* Unwrapped */:
|
|
4946
|
+
case 0 /* ForwardRefHandling.None */:
|
|
4947
|
+
case 2 /* ForwardRefHandling.Unwrapped */:
|
|
4939
4948
|
return query.predicate.expression;
|
|
4940
|
-
case 1 /* Wrapped */:
|
|
4949
|
+
case 1 /* ForwardRefHandling.Wrapped */:
|
|
4941
4950
|
return importExpr(Identifiers.resolveForwardRef).callFn([query.predicate.expression]);
|
|
4942
4951
|
}
|
|
4943
4952
|
}
|
|
@@ -5015,15 +5024,17 @@ function getInstructionStatements(instructions) {
|
|
|
5015
5024
|
const statements = [];
|
|
5016
5025
|
let pendingExpression = null;
|
|
5017
5026
|
let pendingExpressionType = null;
|
|
5027
|
+
let chainLength = 0;
|
|
5018
5028
|
for (const current of instructions) {
|
|
5019
5029
|
const resolvedParams = (_a = (typeof current.paramsOrFn === 'function' ? current.paramsOrFn() : current.paramsOrFn)) !== null && _a !== void 0 ? _a : [];
|
|
5020
5030
|
const params = Array.isArray(resolvedParams) ? resolvedParams : [resolvedParams];
|
|
5021
5031
|
// If the current instruction is the same as the previous one
|
|
5022
5032
|
// and it can be chained, add another call to the chain.
|
|
5023
|
-
if (pendingExpressionType === current.reference &&
|
|
5033
|
+
if (chainLength < MAX_CHAIN_LENGTH && pendingExpressionType === current.reference &&
|
|
5024
5034
|
CHAINABLE_INSTRUCTIONS.has(pendingExpressionType)) {
|
|
5025
5035
|
// We'll always have a pending expression when there's a pending expression type.
|
|
5026
5036
|
pendingExpression = pendingExpression.callFn(params, pendingExpression.sourceSpan);
|
|
5037
|
+
chainLength++;
|
|
5027
5038
|
}
|
|
5028
5039
|
else {
|
|
5029
5040
|
if (pendingExpression !== null) {
|
|
@@ -5031,6 +5042,7 @@ function getInstructionStatements(instructions) {
|
|
|
5031
5042
|
}
|
|
5032
5043
|
pendingExpression = invokeInstruction(current.span, current.reference, params);
|
|
5033
5044
|
pendingExpressionType = current.reference;
|
|
5045
|
+
chainLength = 0;
|
|
5034
5046
|
}
|
|
5035
5047
|
}
|
|
5036
5048
|
// Since the current instruction adds the previous one to the statements,
|
|
@@ -5326,7 +5338,7 @@ class ParseLocation {
|
|
|
5326
5338
|
const ch = source.charCodeAt(offset);
|
|
5327
5339
|
if (ch == $LF) {
|
|
5328
5340
|
line--;
|
|
5329
|
-
const priorLine = source.
|
|
5341
|
+
const priorLine = source.substring(0, offset - 1).lastIndexOf(String.fromCharCode($LF));
|
|
5330
5342
|
col = priorLine > 0 ? offset - priorLine : offset;
|
|
5331
5343
|
}
|
|
5332
5344
|
else {
|
|
@@ -5881,43 +5893,78 @@ class R3JitReflector {
|
|
|
5881
5893
|
* Use of this source code is governed by an MIT-style license that can be
|
|
5882
5894
|
* found in the LICENSE file at https://angular.io/license
|
|
5883
5895
|
*/
|
|
5896
|
+
/**
|
|
5897
|
+
* How the selector scope of an NgModule (its declarations, imports, and exports) should be emitted
|
|
5898
|
+
* as a part of the NgModule definition.
|
|
5899
|
+
*/
|
|
5900
|
+
exports.R3SelectorScopeMode = void 0;
|
|
5901
|
+
(function (R3SelectorScopeMode) {
|
|
5902
|
+
/**
|
|
5903
|
+
* Emit the declarations inline into the module definition.
|
|
5904
|
+
*
|
|
5905
|
+
* This option is useful in certain contexts where it's known that JIT support is required. The
|
|
5906
|
+
* tradeoff here is that this emit style prevents directives and pipes from being tree-shaken if
|
|
5907
|
+
* they are unused, but the NgModule is used.
|
|
5908
|
+
*/
|
|
5909
|
+
R3SelectorScopeMode[R3SelectorScopeMode["Inline"] = 0] = "Inline";
|
|
5910
|
+
/**
|
|
5911
|
+
* Emit the declarations using a side effectful function call, `ɵɵsetNgModuleScope`, that is
|
|
5912
|
+
* guarded with the `ngJitMode` flag.
|
|
5913
|
+
*
|
|
5914
|
+
* This form of emit supports JIT and can be optimized away if the `ngJitMode` flag is set to
|
|
5915
|
+
* false, which allows unused directives and pipes to be tree-shaken.
|
|
5916
|
+
*/
|
|
5917
|
+
R3SelectorScopeMode[R3SelectorScopeMode["SideEffect"] = 1] = "SideEffect";
|
|
5918
|
+
/**
|
|
5919
|
+
* Don't generate selector scopes at all.
|
|
5920
|
+
*
|
|
5921
|
+
* This is useful for contexts where JIT support is known to be unnecessary.
|
|
5922
|
+
*/
|
|
5923
|
+
R3SelectorScopeMode[R3SelectorScopeMode["Omit"] = 2] = "Omit";
|
|
5924
|
+
})(exports.R3SelectorScopeMode || (exports.R3SelectorScopeMode = {}));
|
|
5884
5925
|
/**
|
|
5885
5926
|
* Construct an `R3NgModuleDef` for the given `R3NgModuleMetadata`.
|
|
5886
5927
|
*/
|
|
5887
5928
|
function compileNgModule(meta) {
|
|
5888
|
-
const { internalType, bootstrap, declarations, imports, exports, schemas, containsForwardDecls,
|
|
5929
|
+
const { adjacentType, internalType, bootstrap, declarations, imports, exports: exports$1, schemas, containsForwardDecls, selectorScopeMode, id } = meta;
|
|
5889
5930
|
const statements = [];
|
|
5890
5931
|
const definitionMap = new DefinitionMap();
|
|
5891
5932
|
definitionMap.set('type', internalType);
|
|
5892
5933
|
if (bootstrap.length > 0) {
|
|
5893
5934
|
definitionMap.set('bootstrap', refsToArray(bootstrap, containsForwardDecls));
|
|
5894
5935
|
}
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5936
|
+
if (selectorScopeMode === exports.R3SelectorScopeMode.Inline) {
|
|
5937
|
+
// If requested to emit scope information inline, pass the `declarations`, `imports` and
|
|
5938
|
+
// `exports` to the `ɵɵdefineNgModule()` call directly.
|
|
5898
5939
|
if (declarations.length > 0) {
|
|
5899
5940
|
definitionMap.set('declarations', refsToArray(declarations, containsForwardDecls));
|
|
5900
5941
|
}
|
|
5901
5942
|
if (imports.length > 0) {
|
|
5902
5943
|
definitionMap.set('imports', refsToArray(imports, containsForwardDecls));
|
|
5903
5944
|
}
|
|
5904
|
-
if (exports.length > 0) {
|
|
5905
|
-
definitionMap.set('exports', refsToArray(exports, containsForwardDecls));
|
|
5945
|
+
if (exports$1.length > 0) {
|
|
5946
|
+
definitionMap.set('exports', refsToArray(exports$1, containsForwardDecls));
|
|
5906
5947
|
}
|
|
5907
5948
|
}
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5949
|
+
else if (selectorScopeMode === exports.R3SelectorScopeMode.SideEffect) {
|
|
5950
|
+
// In this mode, scope information is not passed into `ɵɵdefineNgModule` as it
|
|
5951
|
+
// would prevent tree-shaking of the declarations, imports and exports references. Instead, it's
|
|
5952
|
+
// patched onto the NgModule definition with a `ɵɵsetNgModuleScope` call that's guarded by the
|
|
5953
|
+
// `ngJitMode` flag.
|
|
5911
5954
|
const setNgModuleScopeCall = generateSetNgModuleScopeCall(meta);
|
|
5912
5955
|
if (setNgModuleScopeCall !== null) {
|
|
5913
5956
|
statements.push(setNgModuleScopeCall);
|
|
5914
5957
|
}
|
|
5915
5958
|
}
|
|
5959
|
+
else ;
|
|
5916
5960
|
if (schemas !== null && schemas.length > 0) {
|
|
5917
5961
|
definitionMap.set('schemas', literalArr(schemas.map(ref => ref.value)));
|
|
5918
5962
|
}
|
|
5919
5963
|
if (id !== null) {
|
|
5920
5964
|
definitionMap.set('id', id);
|
|
5965
|
+
// Generate a side-effectful call to register this NgModule by its id, as per the semantics of
|
|
5966
|
+
// NgModule ids.
|
|
5967
|
+
statements.push(importExpr(Identifiers.registerNgModuleType).callFn([adjacentType, id]).toStmt());
|
|
5921
5968
|
}
|
|
5922
5969
|
const expression = importExpr(Identifiers.defineNgModule).callFn([definitionMap.toLiteralMap()], undefined, true);
|
|
5923
5970
|
const type = createNgModuleType(meta);
|
|
@@ -6013,6 +6060,9 @@ function compilePipeFromMetadata(metadata) {
|
|
|
6013
6060
|
definitionMapValues.push({ key: 'type', value: metadata.type.value, quoted: false });
|
|
6014
6061
|
// e.g. `pure: true`
|
|
6015
6062
|
definitionMapValues.push({ key: 'pure', value: literal(metadata.pure), quoted: false });
|
|
6063
|
+
if (metadata.isStandalone) {
|
|
6064
|
+
definitionMapValues.push({ key: 'standalone', value: literal(true), quoted: false });
|
|
6065
|
+
}
|
|
6016
6066
|
const expression = importExpr(Identifiers.definePipe).callFn([literalMap(definitionMapValues)], undefined, true);
|
|
6017
6067
|
const type = createPipeType(metadata);
|
|
6018
6068
|
return { expression, type, statements: [] };
|
|
@@ -6021,9 +6071,24 @@ function createPipeType(metadata) {
|
|
|
6021
6071
|
return new ExpressionType(importExpr(Identifiers.PipeDeclaration, [
|
|
6022
6072
|
typeWithParameters(metadata.type.type, metadata.typeArgumentCount),
|
|
6023
6073
|
new ExpressionType(new LiteralExpr(metadata.pipeName)),
|
|
6074
|
+
new ExpressionType(new LiteralExpr(metadata.isStandalone)),
|
|
6024
6075
|
]));
|
|
6025
6076
|
}
|
|
6026
6077
|
|
|
6078
|
+
/**
|
|
6079
|
+
* @license
|
|
6080
|
+
* Copyright Google LLC All Rights Reserved.
|
|
6081
|
+
*
|
|
6082
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6083
|
+
* found in the LICENSE file at https://angular.io/license
|
|
6084
|
+
*/
|
|
6085
|
+
exports.R3TemplateDependencyKind = void 0;
|
|
6086
|
+
(function (R3TemplateDependencyKind) {
|
|
6087
|
+
R3TemplateDependencyKind[R3TemplateDependencyKind["Directive"] = 0] = "Directive";
|
|
6088
|
+
R3TemplateDependencyKind[R3TemplateDependencyKind["Pipe"] = 1] = "Pipe";
|
|
6089
|
+
R3TemplateDependencyKind[R3TemplateDependencyKind["NgModule"] = 2] = "NgModule";
|
|
6090
|
+
})(exports.R3TemplateDependencyKind || (exports.R3TemplateDependencyKind = {}));
|
|
6091
|
+
|
|
6027
6092
|
/**
|
|
6028
6093
|
* @license
|
|
6029
6094
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -6067,33 +6132,6 @@ class ASTWithName extends AST {
|
|
|
6067
6132
|
this.nameSpan = nameSpan;
|
|
6068
6133
|
}
|
|
6069
6134
|
}
|
|
6070
|
-
/**
|
|
6071
|
-
* Represents a quoted expression of the form:
|
|
6072
|
-
*
|
|
6073
|
-
* quote = prefix `:` uninterpretedExpression
|
|
6074
|
-
* prefix = identifier
|
|
6075
|
-
* uninterpretedExpression = arbitrary string
|
|
6076
|
-
*
|
|
6077
|
-
* A quoted expression is meant to be pre-processed by an AST transformer that
|
|
6078
|
-
* converts it into another AST that no longer contains quoted expressions.
|
|
6079
|
-
* It is meant to allow third-party developers to extend Angular template
|
|
6080
|
-
* expression language. The `uninterpretedExpression` part of the quote is
|
|
6081
|
-
* therefore not interpreted by the Angular's own expression parser.
|
|
6082
|
-
*/
|
|
6083
|
-
class Quote extends AST {
|
|
6084
|
-
constructor(span, sourceSpan, prefix, uninterpretedExpression, location) {
|
|
6085
|
-
super(span, sourceSpan);
|
|
6086
|
-
this.prefix = prefix;
|
|
6087
|
-
this.uninterpretedExpression = uninterpretedExpression;
|
|
6088
|
-
this.location = location;
|
|
6089
|
-
}
|
|
6090
|
-
visit(visitor, context = null) {
|
|
6091
|
-
return visitor.visitQuote(this, context);
|
|
6092
|
-
}
|
|
6093
|
-
toString() {
|
|
6094
|
-
return 'Quote';
|
|
6095
|
-
}
|
|
6096
|
-
}
|
|
6097
6135
|
class EmptyExpr extends AST {
|
|
6098
6136
|
visit(visitor, context = null) {
|
|
6099
6137
|
// do nothing
|
|
@@ -6474,7 +6512,6 @@ class RecursiveAstVisitor {
|
|
|
6474
6512
|
this.visit(ast.receiver, context);
|
|
6475
6513
|
this.visitAll(ast.args, context);
|
|
6476
6514
|
}
|
|
6477
|
-
visitQuote(ast, context) { }
|
|
6478
6515
|
// This is not part of the AstVisitor interface, just a helper method
|
|
6479
6516
|
visitAll(asts, context) {
|
|
6480
6517
|
for (const ast of asts) {
|
|
@@ -6557,9 +6594,6 @@ class AstTransformer {
|
|
|
6557
6594
|
visitChain(ast, context) {
|
|
6558
6595
|
return new Chain(ast.span, ast.sourceSpan, this.visitAll(ast.expressions));
|
|
6559
6596
|
}
|
|
6560
|
-
visitQuote(ast, context) {
|
|
6561
|
-
return new Quote(ast.span, ast.sourceSpan, ast.prefix, ast.uninterpretedExpression, ast.location);
|
|
6562
|
-
}
|
|
6563
6597
|
visitSafeKeyedRead(ast, context) {
|
|
6564
6598
|
return new SafeKeyedRead(ast.span, ast.sourceSpan, ast.receiver.visit(this), ast.key.visit(this));
|
|
6565
6599
|
}
|
|
@@ -6722,9 +6756,6 @@ class AstMemoryEfficientTransformer {
|
|
|
6722
6756
|
}
|
|
6723
6757
|
return ast;
|
|
6724
6758
|
}
|
|
6725
|
-
visitQuote(ast, context) {
|
|
6726
|
-
return ast;
|
|
6727
|
-
}
|
|
6728
6759
|
visitSafeKeyedRead(ast, context) {
|
|
6729
6760
|
const obj = ast.receiver.visit(this);
|
|
6730
6761
|
const key = ast.key.visit(this);
|
|
@@ -7198,10 +7229,6 @@ class _AstToIrVisitor {
|
|
|
7198
7229
|
visitAll(asts, mode) {
|
|
7199
7230
|
return asts.map(ast => this._visit(ast, mode));
|
|
7200
7231
|
}
|
|
7201
|
-
visitQuote(ast, mode) {
|
|
7202
|
-
throw new Error(`Quotes are not supported for evaluation!
|
|
7203
|
-
Statement: ${ast.uninterpretedExpression} located at ${ast.location}`);
|
|
7204
|
-
}
|
|
7205
7232
|
visitCall(ast, mode) {
|
|
7206
7233
|
const leftMostSafe = this.leftMostSafeNode(ast);
|
|
7207
7234
|
if (leftMostSafe) {
|
|
@@ -7387,9 +7414,6 @@ class _AstToIrVisitor {
|
|
|
7387
7414
|
visitPropertyWrite(ast) {
|
|
7388
7415
|
return null;
|
|
7389
7416
|
},
|
|
7390
|
-
visitQuote(ast) {
|
|
7391
|
-
return null;
|
|
7392
|
-
},
|
|
7393
7417
|
visitSafePropertyRead(ast) {
|
|
7394
7418
|
return visit(this, ast.receiver) || ast;
|
|
7395
7419
|
},
|
|
@@ -7466,9 +7490,6 @@ class _AstToIrVisitor {
|
|
|
7466
7490
|
visitPropertyWrite(ast) {
|
|
7467
7491
|
return false;
|
|
7468
7492
|
},
|
|
7469
|
-
visitQuote(ast) {
|
|
7470
|
-
return false;
|
|
7471
|
-
},
|
|
7472
7493
|
visitSafePropertyRead(ast) {
|
|
7473
7494
|
return false;
|
|
7474
7495
|
},
|
|
@@ -8320,7 +8341,7 @@ function parse(value) {
|
|
|
8320
8341
|
const styles = [];
|
|
8321
8342
|
let i = 0;
|
|
8322
8343
|
let parenDepth = 0;
|
|
8323
|
-
let quote = 0 /* QuoteNone */;
|
|
8344
|
+
let quote = 0 /* Char.QuoteNone */;
|
|
8324
8345
|
let valueStart = 0;
|
|
8325
8346
|
let propStart = 0;
|
|
8326
8347
|
let currentProp = null;
|
|
@@ -8328,41 +8349,41 @@ function parse(value) {
|
|
|
8328
8349
|
while (i < value.length) {
|
|
8329
8350
|
const token = value.charCodeAt(i++);
|
|
8330
8351
|
switch (token) {
|
|
8331
|
-
case 40 /* OpenParen */:
|
|
8352
|
+
case 40 /* Char.OpenParen */:
|
|
8332
8353
|
parenDepth++;
|
|
8333
8354
|
break;
|
|
8334
|
-
case 41 /* CloseParen */:
|
|
8355
|
+
case 41 /* Char.CloseParen */:
|
|
8335
8356
|
parenDepth--;
|
|
8336
8357
|
break;
|
|
8337
|
-
case 39 /* QuoteSingle */:
|
|
8358
|
+
case 39 /* Char.QuoteSingle */:
|
|
8338
8359
|
// valueStart needs to be there since prop values don't
|
|
8339
8360
|
// have quotes in CSS
|
|
8340
8361
|
valueHasQuotes = valueHasQuotes || valueStart > 0;
|
|
8341
|
-
if (quote === 0 /* QuoteNone */) {
|
|
8342
|
-
quote = 39 /* QuoteSingle */;
|
|
8362
|
+
if (quote === 0 /* Char.QuoteNone */) {
|
|
8363
|
+
quote = 39 /* Char.QuoteSingle */;
|
|
8343
8364
|
}
|
|
8344
|
-
else if (quote === 39 /* QuoteSingle */ && value.charCodeAt(i - 1) !== 92 /* BackSlash */) {
|
|
8345
|
-
quote = 0 /* QuoteNone */;
|
|
8365
|
+
else if (quote === 39 /* Char.QuoteSingle */ && value.charCodeAt(i - 1) !== 92 /* Char.BackSlash */) {
|
|
8366
|
+
quote = 0 /* Char.QuoteNone */;
|
|
8346
8367
|
}
|
|
8347
8368
|
break;
|
|
8348
|
-
case 34 /* QuoteDouble */:
|
|
8369
|
+
case 34 /* Char.QuoteDouble */:
|
|
8349
8370
|
// same logic as above
|
|
8350
8371
|
valueHasQuotes = valueHasQuotes || valueStart > 0;
|
|
8351
|
-
if (quote === 0 /* QuoteNone */) {
|
|
8352
|
-
quote = 34 /* QuoteDouble */;
|
|
8372
|
+
if (quote === 0 /* Char.QuoteNone */) {
|
|
8373
|
+
quote = 34 /* Char.QuoteDouble */;
|
|
8353
8374
|
}
|
|
8354
|
-
else if (quote === 34 /* QuoteDouble */ && value.charCodeAt(i - 1) !== 92 /* BackSlash */) {
|
|
8355
|
-
quote = 0 /* QuoteNone */;
|
|
8375
|
+
else if (quote === 34 /* Char.QuoteDouble */ && value.charCodeAt(i - 1) !== 92 /* Char.BackSlash */) {
|
|
8376
|
+
quote = 0 /* Char.QuoteNone */;
|
|
8356
8377
|
}
|
|
8357
8378
|
break;
|
|
8358
|
-
case 58 /* Colon */:
|
|
8359
|
-
if (!currentProp && parenDepth === 0 && quote === 0 /* QuoteNone */) {
|
|
8379
|
+
case 58 /* Char.Colon */:
|
|
8380
|
+
if (!currentProp && parenDepth === 0 && quote === 0 /* Char.QuoteNone */) {
|
|
8360
8381
|
currentProp = hyphenate(value.substring(propStart, i - 1).trim());
|
|
8361
8382
|
valueStart = i;
|
|
8362
8383
|
}
|
|
8363
8384
|
break;
|
|
8364
|
-
case 59 /* Semicolon */:
|
|
8365
|
-
if (currentProp && valueStart > 0 && parenDepth === 0 && quote === 0 /* QuoteNone */) {
|
|
8385
|
+
case 59 /* Char.Semicolon */:
|
|
8386
|
+
if (currentProp && valueStart > 0 && parenDepth === 0 && quote === 0 /* Char.QuoteNone */) {
|
|
8366
8387
|
const styleVal = value.substring(valueStart, i - 1).trim();
|
|
8367
8388
|
styles.push(currentProp, valueHasQuotes ? stripUnnecessaryQuotes(styleVal) : styleVal);
|
|
8368
8389
|
propStart = i;
|
|
@@ -8374,7 +8395,7 @@ function parse(value) {
|
|
|
8374
8395
|
}
|
|
8375
8396
|
}
|
|
8376
8397
|
if (currentProp && valueStart) {
|
|
8377
|
-
const styleVal = value.
|
|
8398
|
+
const styleVal = value.slice(valueStart).trim();
|
|
8378
8399
|
styles.push(currentProp, valueHasQuotes ? stripUnnecessaryQuotes(styleVal) : styleVal);
|
|
8379
8400
|
}
|
|
8380
8401
|
return styles;
|
|
@@ -8382,7 +8403,7 @@ function parse(value) {
|
|
|
8382
8403
|
function stripUnnecessaryQuotes(value) {
|
|
8383
8404
|
const qS = value.charCodeAt(0);
|
|
8384
8405
|
const qE = value.charCodeAt(value.length - 1);
|
|
8385
|
-
if (qS == qE && (qS == 39 /* QuoteSingle */ || qS == 34 /* QuoteDouble */)) {
|
|
8406
|
+
if (qS == qE && (qS == 39 /* Char.QuoteSingle */ || qS == 34 /* Char.QuoteDouble */)) {
|
|
8386
8407
|
const tempValue = value.substring(1, value.length - 1);
|
|
8387
8408
|
// special case to avoid using a multi-quoted string that was just chomped
|
|
8388
8409
|
// (e.g. `font-family: "Verdana", "sans-serif"`)
|
|
@@ -8533,13 +8554,13 @@ class StylingBuilder {
|
|
|
8533
8554
|
let binding = null;
|
|
8534
8555
|
let name = input.name;
|
|
8535
8556
|
switch (input.type) {
|
|
8536
|
-
case 0 /* Property */:
|
|
8557
|
+
case 0 /* BindingType.Property */:
|
|
8537
8558
|
binding = this.registerInputBasedOnName(name, input.value, input.sourceSpan);
|
|
8538
8559
|
break;
|
|
8539
|
-
case 3 /* Style */:
|
|
8560
|
+
case 3 /* BindingType.Style */:
|
|
8540
8561
|
binding = this.registerStyleInput(name, false, input.value, input.sourceSpan, input.unit);
|
|
8541
8562
|
break;
|
|
8542
|
-
case 2 /* Class */:
|
|
8563
|
+
case 2 /* BindingType.Class */:
|
|
8543
8564
|
binding = this.registerClassInput(name, false, input.value, input.sourceSpan);
|
|
8544
8565
|
break;
|
|
8545
8566
|
}
|
|
@@ -8552,7 +8573,7 @@ class StylingBuilder {
|
|
|
8552
8573
|
const isClass = !isStyle && (name === 'class' || prefix === 'class.' || prefix === 'class!');
|
|
8553
8574
|
if (isStyle || isClass) {
|
|
8554
8575
|
const isMapBased = name.charAt(5) !== '.'; // style.prop or class.prop makes this a no
|
|
8555
|
-
const property = name.
|
|
8576
|
+
const property = name.slice(isMapBased ? 5 : 6); // the dot explains why there's a +1
|
|
8556
8577
|
if (isStyle) {
|
|
8557
8578
|
binding = this.registerStyleInput(property, isMapBased, expression, sourceSpan);
|
|
8558
8579
|
}
|
|
@@ -8638,14 +8659,14 @@ class StylingBuilder {
|
|
|
8638
8659
|
populateInitialStylingAttrs(attrs) {
|
|
8639
8660
|
// [CLASS_MARKER, 'foo', 'bar', 'baz' ...]
|
|
8640
8661
|
if (this._initialClassValues.length) {
|
|
8641
|
-
attrs.push(literal(1 /* Classes */));
|
|
8662
|
+
attrs.push(literal(1 /* AttributeMarker.Classes */));
|
|
8642
8663
|
for (let i = 0; i < this._initialClassValues.length; i++) {
|
|
8643
8664
|
attrs.push(literal(this._initialClassValues[i]));
|
|
8644
8665
|
}
|
|
8645
8666
|
}
|
|
8646
8667
|
// [STYLE_MARKER, 'width', '200px', 'height', '100px', ...]
|
|
8647
8668
|
if (this._initialStyleValues.length) {
|
|
8648
|
-
attrs.push(literal(2 /* Styles */));
|
|
8669
|
+
attrs.push(literal(2 /* AttributeMarker.Styles */));
|
|
8649
8670
|
for (let i = 0; i < this._initialStyleValues.length; i += 2) {
|
|
8650
8671
|
attrs.push(literal(this._initialStyleValues[i]), literal(this._initialStyleValues[i + 1]));
|
|
8651
8672
|
}
|
|
@@ -8826,7 +8847,7 @@ function parseProperty(name) {
|
|
|
8826
8847
|
let property = name;
|
|
8827
8848
|
const unitIndex = name.lastIndexOf('.');
|
|
8828
8849
|
if (unitIndex > 0) {
|
|
8829
|
-
suffix = name.
|
|
8850
|
+
suffix = name.slice(unitIndex + 1);
|
|
8830
8851
|
property = name.substring(0, unitIndex);
|
|
8831
8852
|
}
|
|
8832
8853
|
return { property, suffix, hasOverrideFlag };
|
|
@@ -9375,9 +9396,9 @@ class Parser$1 {
|
|
|
9375
9396
|
this._checkNoInterpolation(input, location, interpolationConfig);
|
|
9376
9397
|
const sourceToLex = this._stripComments(input);
|
|
9377
9398
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
9378
|
-
let flags = 1 /* Action */;
|
|
9399
|
+
let flags = 1 /* ParseFlags.Action */;
|
|
9379
9400
|
if (isAssignmentEvent) {
|
|
9380
|
-
flags |= 2 /* AssignmentEvent */;
|
|
9401
|
+
flags |= 2 /* ParseFlags.AssignmentEvent */;
|
|
9381
9402
|
}
|
|
9382
9403
|
const ast = new _ParseAST(input, location, absoluteOffset, tokens, flags, this.errors, 0).parseChain();
|
|
9383
9404
|
return new ASTWithSource(ast, input, location, absoluteOffset, this.errors);
|
|
@@ -9403,31 +9424,12 @@ class Parser$1 {
|
|
|
9403
9424
|
this.errors.push(new ParserError(message, input, errLocation, ctxLocation));
|
|
9404
9425
|
}
|
|
9405
9426
|
_parseBindingAst(input, location, absoluteOffset, interpolationConfig) {
|
|
9406
|
-
// Quotes expressions use 3rd-party expression language. We don't want to use
|
|
9407
|
-
// our lexer or parser for that, so we check for that ahead of time.
|
|
9408
|
-
const quote = this._parseQuote(input, location, absoluteOffset);
|
|
9409
|
-
if (quote != null) {
|
|
9410
|
-
return quote;
|
|
9411
|
-
}
|
|
9412
9427
|
this._checkNoInterpolation(input, location, interpolationConfig);
|
|
9413
9428
|
const sourceToLex = this._stripComments(input);
|
|
9414
9429
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
9415
|
-
return new _ParseAST(input, location, absoluteOffset, tokens, 0 /* None */, this.errors, 0)
|
|
9430
|
+
return new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, this.errors, 0)
|
|
9416
9431
|
.parseChain();
|
|
9417
9432
|
}
|
|
9418
|
-
_parseQuote(input, location, absoluteOffset) {
|
|
9419
|
-
if (input == null)
|
|
9420
|
-
return null;
|
|
9421
|
-
const prefixSeparatorIndex = input.indexOf(':');
|
|
9422
|
-
if (prefixSeparatorIndex == -1)
|
|
9423
|
-
return null;
|
|
9424
|
-
const prefix = input.substring(0, prefixSeparatorIndex).trim();
|
|
9425
|
-
if (!isIdentifier(prefix))
|
|
9426
|
-
return null;
|
|
9427
|
-
const uninterpretedExpression = input.substring(prefixSeparatorIndex + 1);
|
|
9428
|
-
const span = new ParseSpan(0, input.length);
|
|
9429
|
-
return new Quote(span, span.toAbsolute(absoluteOffset), prefix, uninterpretedExpression, location);
|
|
9430
|
-
}
|
|
9431
9433
|
/**
|
|
9432
9434
|
* Parse microsyntax template expression and return a list of bindings or
|
|
9433
9435
|
* parsing errors in case the given expression is invalid.
|
|
@@ -9456,7 +9458,7 @@ class Parser$1 {
|
|
|
9456
9458
|
*/
|
|
9457
9459
|
parseTemplateBindings(templateKey, templateValue, templateUrl, absoluteKeyOffset, absoluteValueOffset) {
|
|
9458
9460
|
const tokens = this._lexer.tokenize(templateValue);
|
|
9459
|
-
const parser = new _ParseAST(templateValue, templateUrl, absoluteValueOffset, tokens, 0 /* None */, this.errors, 0 /* relative offset */);
|
|
9461
|
+
const parser = new _ParseAST(templateValue, templateUrl, absoluteValueOffset, tokens, 0 /* ParseFlags.None */, this.errors, 0 /* relative offset */);
|
|
9460
9462
|
return parser.parseTemplateBindings({
|
|
9461
9463
|
source: templateKey,
|
|
9462
9464
|
span: new AbsoluteSourceSpan(absoluteKeyOffset, absoluteKeyOffset + templateKey.length),
|
|
@@ -9471,7 +9473,7 @@ class Parser$1 {
|
|
|
9471
9473
|
const expressionText = expressions[i].text;
|
|
9472
9474
|
const sourceToLex = this._stripComments(expressionText);
|
|
9473
9475
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
9474
|
-
const ast = new _ParseAST(input, location, absoluteOffset, tokens, 0 /* None */, this.errors, offsets[i])
|
|
9476
|
+
const ast = new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, this.errors, offsets[i])
|
|
9475
9477
|
.parseChain();
|
|
9476
9478
|
expressionNodes.push(ast);
|
|
9477
9479
|
}
|
|
@@ -9485,7 +9487,7 @@ class Parser$1 {
|
|
|
9485
9487
|
parseInterpolationExpression(expression, location, absoluteOffset) {
|
|
9486
9488
|
const sourceToLex = this._stripComments(expression);
|
|
9487
9489
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
9488
|
-
const ast = new _ParseAST(expression, location, absoluteOffset, tokens, 0 /* None */, this.errors, 0)
|
|
9490
|
+
const ast = new _ParseAST(expression, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, this.errors, 0)
|
|
9489
9491
|
.parseChain();
|
|
9490
9492
|
const strings = ['', '']; // The prefix and suffix strings are both empty
|
|
9491
9493
|
return this.createInterpolationAst(strings, [ast], expression, location, absoluteOffset);
|
|
@@ -9842,7 +9844,7 @@ class _ParseAST {
|
|
|
9842
9844
|
const expr = this.parsePipe();
|
|
9843
9845
|
exprs.push(expr);
|
|
9844
9846
|
if (this.consumeOptionalCharacter($SEMICOLON)) {
|
|
9845
|
-
if (!(this.parseFlags & 1 /* Action */)) {
|
|
9847
|
+
if (!(this.parseFlags & 1 /* ParseFlags.Action */)) {
|
|
9846
9848
|
this.error('Binding expression cannot contain chained expression');
|
|
9847
9849
|
}
|
|
9848
9850
|
while (this.consumeOptionalCharacter($SEMICOLON)) {
|
|
@@ -9866,7 +9868,7 @@ class _ParseAST {
|
|
|
9866
9868
|
const start = this.inputIndex;
|
|
9867
9869
|
let result = this.parseExpression();
|
|
9868
9870
|
if (this.consumeOptionalOperator('|')) {
|
|
9869
|
-
if (this.parseFlags & 1 /* Action */) {
|
|
9871
|
+
if (this.parseFlags & 1 /* ParseFlags.Action */) {
|
|
9870
9872
|
this.error('Cannot have a pipe in an action expression');
|
|
9871
9873
|
}
|
|
9872
9874
|
do {
|
|
@@ -10219,7 +10221,7 @@ class _ParseAST {
|
|
|
10219
10221
|
}
|
|
10220
10222
|
else {
|
|
10221
10223
|
if (this.consumeOptionalAssignment()) {
|
|
10222
|
-
if (!(this.parseFlags & 1 /* Action */)) {
|
|
10224
|
+
if (!(this.parseFlags & 1 /* ParseFlags.Action */)) {
|
|
10223
10225
|
this.error('Bindings cannot contain assignments');
|
|
10224
10226
|
return new EmptyExpr(this.span(start), this.sourceSpan(start));
|
|
10225
10227
|
}
|
|
@@ -10251,7 +10253,7 @@ class _ParseAST {
|
|
|
10251
10253
|
// primary expression is substituted as LHS of the assignment operator to achieve
|
|
10252
10254
|
// two-way-binding, such that the LHS could be the non-null operator. The grammar doesn't
|
|
10253
10255
|
// naturally allow for this syntax, so assignment events are parsed specially.
|
|
10254
|
-
if ((this.parseFlags & 2 /* AssignmentEvent */) && this.next.isOperator('!') &&
|
|
10256
|
+
if ((this.parseFlags & 2 /* ParseFlags.AssignmentEvent */) && this.next.isOperator('!') &&
|
|
10255
10257
|
this.peek(1).isOperator('=')) {
|
|
10256
10258
|
// First skip over the ! operator.
|
|
10257
10259
|
this.advance();
|
|
@@ -10573,7 +10575,7 @@ function getIndexMapForOriginalTemplate(interpolatedTokens) {
|
|
|
10573
10575
|
let tokenIndex = 0;
|
|
10574
10576
|
while (tokenIndex < interpolatedTokens.length) {
|
|
10575
10577
|
const currentToken = interpolatedTokens[tokenIndex];
|
|
10576
|
-
if (currentToken.type === 9 /* ENCODED_ENTITY */) {
|
|
10578
|
+
if (currentToken.type === 9 /* MlParserTokenType.ENCODED_ENTITY */) {
|
|
10577
10579
|
const [decoded, encoded] = currentToken.parts;
|
|
10578
10580
|
consumedInOriginalTemplate += encoded.length;
|
|
10579
10581
|
consumedInInput += decoded.length;
|
|
@@ -12971,14 +12973,14 @@ class _Tokenizer {
|
|
|
12971
12973
|
else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {
|
|
12972
12974
|
// In (possibly interpolated) text the end of the text is given by `isTextEnd()`, while
|
|
12973
12975
|
// the premature end of an interpolation is given by the start of a new HTML element.
|
|
12974
|
-
this._consumeWithInterpolation(5 /* TEXT */, 8 /* INTERPOLATION */, () => this._isTextEnd(), () => this._isTagStart());
|
|
12976
|
+
this._consumeWithInterpolation(5 /* TokenType.TEXT */, 8 /* TokenType.INTERPOLATION */, () => this._isTextEnd(), () => this._isTagStart());
|
|
12975
12977
|
}
|
|
12976
12978
|
}
|
|
12977
12979
|
catch (e) {
|
|
12978
12980
|
this.handleError(e);
|
|
12979
12981
|
}
|
|
12980
12982
|
}
|
|
12981
|
-
this._beginToken(24 /* EOF */);
|
|
12983
|
+
this._beginToken(24 /* TokenType.EOF */);
|
|
12982
12984
|
this._endToken([]);
|
|
12983
12985
|
}
|
|
12984
12986
|
/**
|
|
@@ -13122,7 +13124,7 @@ class _Tokenizer {
|
|
|
13122
13124
|
return char;
|
|
13123
13125
|
}
|
|
13124
13126
|
_consumeEntity(textTokenType) {
|
|
13125
|
-
this._beginToken(9 /* ENCODED_ENTITY */);
|
|
13127
|
+
this._beginToken(9 /* TokenType.ENCODED_ENTITY */);
|
|
13126
13128
|
const start = this._cursor.clone();
|
|
13127
13129
|
this._cursor.advance();
|
|
13128
13130
|
if (this._attemptCharCode($HASH)) {
|
|
@@ -13168,7 +13170,7 @@ class _Tokenizer {
|
|
|
13168
13170
|
}
|
|
13169
13171
|
}
|
|
13170
13172
|
_consumeRawText(consumeEntities, endMarkerPredicate) {
|
|
13171
|
-
this._beginToken(consumeEntities ? 6 /* ESCAPABLE_RAW_TEXT */ : 7 /* RAW_TEXT */);
|
|
13173
|
+
this._beginToken(consumeEntities ? 6 /* TokenType.ESCAPABLE_RAW_TEXT */ : 7 /* TokenType.RAW_TEXT */);
|
|
13172
13174
|
const parts = [];
|
|
13173
13175
|
while (true) {
|
|
13174
13176
|
const tagCloseStart = this._cursor.clone();
|
|
@@ -13180,8 +13182,8 @@ class _Tokenizer {
|
|
|
13180
13182
|
if (consumeEntities && this._cursor.peek() === $AMPERSAND) {
|
|
13181
13183
|
this._endToken([this._processCarriageReturns(parts.join(''))]);
|
|
13182
13184
|
parts.length = 0;
|
|
13183
|
-
this._consumeEntity(6 /* ESCAPABLE_RAW_TEXT */);
|
|
13184
|
-
this._beginToken(6 /* ESCAPABLE_RAW_TEXT */);
|
|
13185
|
+
this._consumeEntity(6 /* TokenType.ESCAPABLE_RAW_TEXT */);
|
|
13186
|
+
this._beginToken(6 /* TokenType.ESCAPABLE_RAW_TEXT */);
|
|
13185
13187
|
}
|
|
13186
13188
|
else {
|
|
13187
13189
|
parts.push(this._readChar());
|
|
@@ -13190,25 +13192,25 @@ class _Tokenizer {
|
|
|
13190
13192
|
this._endToken([this._processCarriageReturns(parts.join(''))]);
|
|
13191
13193
|
}
|
|
13192
13194
|
_consumeComment(start) {
|
|
13193
|
-
this._beginToken(10 /* COMMENT_START */, start);
|
|
13195
|
+
this._beginToken(10 /* TokenType.COMMENT_START */, start);
|
|
13194
13196
|
this._requireCharCode($MINUS);
|
|
13195
13197
|
this._endToken([]);
|
|
13196
13198
|
this._consumeRawText(false, () => this._attemptStr('-->'));
|
|
13197
|
-
this._beginToken(11 /* COMMENT_END */);
|
|
13199
|
+
this._beginToken(11 /* TokenType.COMMENT_END */);
|
|
13198
13200
|
this._requireStr('-->');
|
|
13199
13201
|
this._endToken([]);
|
|
13200
13202
|
}
|
|
13201
13203
|
_consumeCdata(start) {
|
|
13202
|
-
this._beginToken(12 /* CDATA_START */, start);
|
|
13204
|
+
this._beginToken(12 /* TokenType.CDATA_START */, start);
|
|
13203
13205
|
this._requireStr('CDATA[');
|
|
13204
13206
|
this._endToken([]);
|
|
13205
13207
|
this._consumeRawText(false, () => this._attemptStr(']]>'));
|
|
13206
|
-
this._beginToken(13 /* CDATA_END */);
|
|
13208
|
+
this._beginToken(13 /* TokenType.CDATA_END */);
|
|
13207
13209
|
this._requireStr(']]>');
|
|
13208
13210
|
this._endToken([]);
|
|
13209
13211
|
}
|
|
13210
13212
|
_consumeDocType(start) {
|
|
13211
|
-
this._beginToken(18 /* DOC_TYPE */, start);
|
|
13213
|
+
this._beginToken(18 /* TokenType.DOC_TYPE */, start);
|
|
13212
13214
|
const contentStart = this._cursor.clone();
|
|
13213
13215
|
this._attemptUntilChar($GT);
|
|
13214
13216
|
const content = this._cursor.getChars(contentStart);
|
|
@@ -13262,12 +13264,12 @@ class _Tokenizer {
|
|
|
13262
13264
|
if (e instanceof _ControlFlowError) {
|
|
13263
13265
|
if (openTagToken) {
|
|
13264
13266
|
// We errored before we could close the opening tag, so it is incomplete.
|
|
13265
|
-
openTagToken.type = 4 /* INCOMPLETE_TAG_OPEN */;
|
|
13267
|
+
openTagToken.type = 4 /* TokenType.INCOMPLETE_TAG_OPEN */;
|
|
13266
13268
|
}
|
|
13267
13269
|
else {
|
|
13268
13270
|
// When the start tag is invalid, assume we want a "<" as text.
|
|
13269
13271
|
// Back to back text tokens are merged at the end.
|
|
13270
|
-
this._beginToken(5 /* TEXT */, start);
|
|
13272
|
+
this._beginToken(5 /* TokenType.TEXT */, start);
|
|
13271
13273
|
this._endToken(['<']);
|
|
13272
13274
|
}
|
|
13273
13275
|
return;
|
|
@@ -13294,13 +13296,13 @@ class _Tokenizer {
|
|
|
13294
13296
|
this._attemptCharCodeUntilFn(isNotWhitespace);
|
|
13295
13297
|
return this._attemptCharCode($GT);
|
|
13296
13298
|
});
|
|
13297
|
-
this._beginToken(3 /* TAG_CLOSE */);
|
|
13299
|
+
this._beginToken(3 /* TokenType.TAG_CLOSE */);
|
|
13298
13300
|
this._requireCharCodeUntilFn(code => code === $GT, 3);
|
|
13299
13301
|
this._cursor.advance(); // Consume the `>`
|
|
13300
13302
|
this._endToken([prefix, tagName]);
|
|
13301
13303
|
}
|
|
13302
13304
|
_consumeTagOpenStart(start) {
|
|
13303
|
-
this._beginToken(0 /* TAG_OPEN_START */, start);
|
|
13305
|
+
this._beginToken(0 /* TokenType.TAG_OPEN_START */, start);
|
|
13304
13306
|
const parts = this._consumePrefixAndName();
|
|
13305
13307
|
return this._endToken(parts);
|
|
13306
13308
|
}
|
|
@@ -13309,7 +13311,7 @@ class _Tokenizer {
|
|
|
13309
13311
|
if (attrNameStart === $SQ || attrNameStart === $DQ) {
|
|
13310
13312
|
throw this._createError(_unexpectedCharacterErrorMsg(attrNameStart), this._cursor.getSpan());
|
|
13311
13313
|
}
|
|
13312
|
-
this._beginToken(14 /* ATTR_NAME */);
|
|
13314
|
+
this._beginToken(14 /* TokenType.ATTR_NAME */);
|
|
13313
13315
|
const prefixAndName = this._consumePrefixAndName();
|
|
13314
13316
|
this._endToken(prefixAndName);
|
|
13315
13317
|
}
|
|
@@ -13320,27 +13322,27 @@ class _Tokenizer {
|
|
|
13320
13322
|
// In an attribute then end of the attribute value and the premature end to an interpolation
|
|
13321
13323
|
// are both triggered by the `quoteChar`.
|
|
13322
13324
|
const endPredicate = () => this._cursor.peek() === quoteChar;
|
|
13323
|
-
this._consumeWithInterpolation(16 /* ATTR_VALUE_TEXT */, 17 /* ATTR_VALUE_INTERPOLATION */, endPredicate, endPredicate);
|
|
13325
|
+
this._consumeWithInterpolation(16 /* TokenType.ATTR_VALUE_TEXT */, 17 /* TokenType.ATTR_VALUE_INTERPOLATION */, endPredicate, endPredicate);
|
|
13324
13326
|
this._consumeQuote(quoteChar);
|
|
13325
13327
|
}
|
|
13326
13328
|
else {
|
|
13327
13329
|
const endPredicate = () => isNameEnd(this._cursor.peek());
|
|
13328
|
-
this._consumeWithInterpolation(16 /* ATTR_VALUE_TEXT */, 17 /* ATTR_VALUE_INTERPOLATION */, endPredicate, endPredicate);
|
|
13330
|
+
this._consumeWithInterpolation(16 /* TokenType.ATTR_VALUE_TEXT */, 17 /* TokenType.ATTR_VALUE_INTERPOLATION */, endPredicate, endPredicate);
|
|
13329
13331
|
}
|
|
13330
13332
|
}
|
|
13331
13333
|
_consumeQuote(quoteChar) {
|
|
13332
|
-
this._beginToken(15 /* ATTR_QUOTE */);
|
|
13334
|
+
this._beginToken(15 /* TokenType.ATTR_QUOTE */);
|
|
13333
13335
|
this._requireCharCode(quoteChar);
|
|
13334
13336
|
this._endToken([String.fromCodePoint(quoteChar)]);
|
|
13335
13337
|
}
|
|
13336
13338
|
_consumeTagOpenEnd() {
|
|
13337
|
-
const tokenType = this._attemptCharCode($SLASH) ? 2 /* TAG_OPEN_END_VOID */ : 1 /* TAG_OPEN_END */;
|
|
13339
|
+
const tokenType = this._attemptCharCode($SLASH) ? 2 /* TokenType.TAG_OPEN_END_VOID */ : 1 /* TokenType.TAG_OPEN_END */;
|
|
13338
13340
|
this._beginToken(tokenType);
|
|
13339
13341
|
this._requireCharCode($GT);
|
|
13340
13342
|
this._endToken([]);
|
|
13341
13343
|
}
|
|
13342
13344
|
_consumeTagClose(start) {
|
|
13343
|
-
this._beginToken(3 /* TAG_CLOSE */, start);
|
|
13345
|
+
this._beginToken(3 /* TokenType.TAG_CLOSE */, start);
|
|
13344
13346
|
this._attemptCharCodeUntilFn(isNotWhitespace);
|
|
13345
13347
|
const prefixAndName = this._consumePrefixAndName();
|
|
13346
13348
|
this._attemptCharCodeUntilFn(isNotWhitespace);
|
|
@@ -13348,11 +13350,11 @@ class _Tokenizer {
|
|
|
13348
13350
|
this._endToken(prefixAndName);
|
|
13349
13351
|
}
|
|
13350
13352
|
_consumeExpansionFormStart() {
|
|
13351
|
-
this._beginToken(19 /* EXPANSION_FORM_START */);
|
|
13353
|
+
this._beginToken(19 /* TokenType.EXPANSION_FORM_START */);
|
|
13352
13354
|
this._requireCharCode($LBRACE);
|
|
13353
13355
|
this._endToken([]);
|
|
13354
|
-
this._expansionCaseStack.push(19 /* EXPANSION_FORM_START */);
|
|
13355
|
-
this._beginToken(7 /* RAW_TEXT */);
|
|
13356
|
+
this._expansionCaseStack.push(19 /* TokenType.EXPANSION_FORM_START */);
|
|
13357
|
+
this._beginToken(7 /* TokenType.RAW_TEXT */);
|
|
13356
13358
|
const condition = this._readUntil($COMMA);
|
|
13357
13359
|
const normalizedCondition = this._processCarriageReturns(condition);
|
|
13358
13360
|
if (this._i18nNormalizeLineEndingsInICUs) {
|
|
@@ -13368,32 +13370,32 @@ class _Tokenizer {
|
|
|
13368
13370
|
}
|
|
13369
13371
|
this._requireCharCode($COMMA);
|
|
13370
13372
|
this._attemptCharCodeUntilFn(isNotWhitespace);
|
|
13371
|
-
this._beginToken(7 /* RAW_TEXT */);
|
|
13373
|
+
this._beginToken(7 /* TokenType.RAW_TEXT */);
|
|
13372
13374
|
const type = this._readUntil($COMMA);
|
|
13373
13375
|
this._endToken([type]);
|
|
13374
13376
|
this._requireCharCode($COMMA);
|
|
13375
13377
|
this._attemptCharCodeUntilFn(isNotWhitespace);
|
|
13376
13378
|
}
|
|
13377
13379
|
_consumeExpansionCaseStart() {
|
|
13378
|
-
this._beginToken(20 /* EXPANSION_CASE_VALUE */);
|
|
13380
|
+
this._beginToken(20 /* TokenType.EXPANSION_CASE_VALUE */);
|
|
13379
13381
|
const value = this._readUntil($LBRACE).trim();
|
|
13380
13382
|
this._endToken([value]);
|
|
13381
13383
|
this._attemptCharCodeUntilFn(isNotWhitespace);
|
|
13382
|
-
this._beginToken(21 /* EXPANSION_CASE_EXP_START */);
|
|
13384
|
+
this._beginToken(21 /* TokenType.EXPANSION_CASE_EXP_START */);
|
|
13383
13385
|
this._requireCharCode($LBRACE);
|
|
13384
13386
|
this._endToken([]);
|
|
13385
13387
|
this._attemptCharCodeUntilFn(isNotWhitespace);
|
|
13386
|
-
this._expansionCaseStack.push(21 /* EXPANSION_CASE_EXP_START */);
|
|
13388
|
+
this._expansionCaseStack.push(21 /* TokenType.EXPANSION_CASE_EXP_START */);
|
|
13387
13389
|
}
|
|
13388
13390
|
_consumeExpansionCaseEnd() {
|
|
13389
|
-
this._beginToken(22 /* EXPANSION_CASE_EXP_END */);
|
|
13391
|
+
this._beginToken(22 /* TokenType.EXPANSION_CASE_EXP_END */);
|
|
13390
13392
|
this._requireCharCode($RBRACE);
|
|
13391
13393
|
this._endToken([]);
|
|
13392
13394
|
this._attemptCharCodeUntilFn(isNotWhitespace);
|
|
13393
13395
|
this._expansionCaseStack.pop();
|
|
13394
13396
|
}
|
|
13395
13397
|
_consumeExpansionFormEnd() {
|
|
13396
|
-
this._beginToken(23 /* EXPANSION_FORM_END */);
|
|
13398
|
+
this._beginToken(23 /* TokenType.EXPANSION_FORM_END */);
|
|
13397
13399
|
this._requireCharCode($RBRACE);
|
|
13398
13400
|
this._endToken([]);
|
|
13399
13401
|
this._expansionCaseStack.pop();
|
|
@@ -13543,12 +13545,12 @@ class _Tokenizer {
|
|
|
13543
13545
|
_isInExpansionCase() {
|
|
13544
13546
|
return this._expansionCaseStack.length > 0 &&
|
|
13545
13547
|
this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
|
|
13546
|
-
21 /* EXPANSION_CASE_EXP_START */;
|
|
13548
|
+
21 /* TokenType.EXPANSION_CASE_EXP_START */;
|
|
13547
13549
|
}
|
|
13548
13550
|
_isInExpansionForm() {
|
|
13549
13551
|
return this._expansionCaseStack.length > 0 &&
|
|
13550
13552
|
this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
|
|
13551
|
-
19 /* EXPANSION_FORM_START */;
|
|
13553
|
+
19 /* TokenType.EXPANSION_FORM_START */;
|
|
13552
13554
|
}
|
|
13553
13555
|
isExpansionFormStart() {
|
|
13554
13556
|
if (this._cursor.peek() !== $LBRACE) {
|
|
@@ -13595,9 +13597,9 @@ function mergeTextTokens(srcTokens) {
|
|
|
13595
13597
|
let lastDstToken = undefined;
|
|
13596
13598
|
for (let i = 0; i < srcTokens.length; i++) {
|
|
13597
13599
|
const token = srcTokens[i];
|
|
13598
|
-
if ((lastDstToken && lastDstToken.type === 5 /* TEXT */ && token.type === 5 /* TEXT */) ||
|
|
13599
|
-
(lastDstToken && lastDstToken.type === 16 /* ATTR_VALUE_TEXT */ &&
|
|
13600
|
-
token.type === 16 /* ATTR_VALUE_TEXT */)) {
|
|
13600
|
+
if ((lastDstToken && lastDstToken.type === 5 /* TokenType.TEXT */ && token.type === 5 /* TokenType.TEXT */) ||
|
|
13601
|
+
(lastDstToken && lastDstToken.type === 16 /* TokenType.ATTR_VALUE_TEXT */ &&
|
|
13602
|
+
token.type === 16 /* TokenType.ATTR_VALUE_TEXT */)) {
|
|
13601
13603
|
lastDstToken.parts[0] += token.parts[0];
|
|
13602
13604
|
lastDstToken.sourceSpan.end = token.sourceSpan.end;
|
|
13603
13605
|
}
|
|
@@ -13828,7 +13830,7 @@ class EscapedCharacterCursor extends PlainCharacterCursor {
|
|
|
13828
13830
|
}
|
|
13829
13831
|
}
|
|
13830
13832
|
decodeHexDigits(start, length) {
|
|
13831
|
-
const hex = this.input.
|
|
13833
|
+
const hex = this.input.slice(start.internalState.offset, start.internalState.offset + length);
|
|
13832
13834
|
const charCode = parseInt(hex, 16);
|
|
13833
13835
|
if (!isNaN(charCode)) {
|
|
13834
13836
|
return charCode;
|
|
@@ -13890,28 +13892,28 @@ class _TreeBuilder {
|
|
|
13890
13892
|
this._advance();
|
|
13891
13893
|
}
|
|
13892
13894
|
build() {
|
|
13893
|
-
while (this._peek.type !== 24 /* EOF */) {
|
|
13894
|
-
if (this._peek.type === 0 /* TAG_OPEN_START */ ||
|
|
13895
|
-
this._peek.type === 4 /* INCOMPLETE_TAG_OPEN */) {
|
|
13895
|
+
while (this._peek.type !== 24 /* TokenType.EOF */) {
|
|
13896
|
+
if (this._peek.type === 0 /* TokenType.TAG_OPEN_START */ ||
|
|
13897
|
+
this._peek.type === 4 /* TokenType.INCOMPLETE_TAG_OPEN */) {
|
|
13896
13898
|
this._consumeStartTag(this._advance());
|
|
13897
13899
|
}
|
|
13898
|
-
else if (this._peek.type === 3 /* TAG_CLOSE */) {
|
|
13900
|
+
else if (this._peek.type === 3 /* TokenType.TAG_CLOSE */) {
|
|
13899
13901
|
this._consumeEndTag(this._advance());
|
|
13900
13902
|
}
|
|
13901
|
-
else if (this._peek.type === 12 /* CDATA_START */) {
|
|
13903
|
+
else if (this._peek.type === 12 /* TokenType.CDATA_START */) {
|
|
13902
13904
|
this._closeVoidElement();
|
|
13903
13905
|
this._consumeCdata(this._advance());
|
|
13904
13906
|
}
|
|
13905
|
-
else if (this._peek.type === 10 /* COMMENT_START */) {
|
|
13907
|
+
else if (this._peek.type === 10 /* TokenType.COMMENT_START */) {
|
|
13906
13908
|
this._closeVoidElement();
|
|
13907
13909
|
this._consumeComment(this._advance());
|
|
13908
13910
|
}
|
|
13909
|
-
else if (this._peek.type === 5 /* TEXT */ || this._peek.type === 7 /* RAW_TEXT */ ||
|
|
13910
|
-
this._peek.type === 6 /* ESCAPABLE_RAW_TEXT */) {
|
|
13911
|
+
else if (this._peek.type === 5 /* TokenType.TEXT */ || this._peek.type === 7 /* TokenType.RAW_TEXT */ ||
|
|
13912
|
+
this._peek.type === 6 /* TokenType.ESCAPABLE_RAW_TEXT */) {
|
|
13911
13913
|
this._closeVoidElement();
|
|
13912
13914
|
this._consumeText(this._advance());
|
|
13913
13915
|
}
|
|
13914
|
-
else if (this._peek.type === 19 /* EXPANSION_FORM_START */) {
|
|
13916
|
+
else if (this._peek.type === 19 /* TokenType.EXPANSION_FORM_START */) {
|
|
13915
13917
|
this._consumeExpansion(this._advance());
|
|
13916
13918
|
}
|
|
13917
13919
|
else {
|
|
@@ -13937,11 +13939,11 @@ class _TreeBuilder {
|
|
|
13937
13939
|
}
|
|
13938
13940
|
_consumeCdata(_startToken) {
|
|
13939
13941
|
this._consumeText(this._advance());
|
|
13940
|
-
this._advanceIf(13 /* CDATA_END */);
|
|
13942
|
+
this._advanceIf(13 /* TokenType.CDATA_END */);
|
|
13941
13943
|
}
|
|
13942
13944
|
_consumeComment(token) {
|
|
13943
|
-
const text = this._advanceIf(7 /* RAW_TEXT */);
|
|
13944
|
-
this._advanceIf(11 /* COMMENT_END */);
|
|
13945
|
+
const text = this._advanceIf(7 /* TokenType.RAW_TEXT */);
|
|
13946
|
+
this._advanceIf(11 /* TokenType.COMMENT_END */);
|
|
13945
13947
|
const value = text != null ? text.parts[0].trim() : null;
|
|
13946
13948
|
this._addToParent(new Comment(value, token.sourceSpan));
|
|
13947
13949
|
}
|
|
@@ -13950,14 +13952,14 @@ class _TreeBuilder {
|
|
|
13950
13952
|
const type = this._advance();
|
|
13951
13953
|
const cases = [];
|
|
13952
13954
|
// read =
|
|
13953
|
-
while (this._peek.type === 20 /* EXPANSION_CASE_VALUE */) {
|
|
13955
|
+
while (this._peek.type === 20 /* TokenType.EXPANSION_CASE_VALUE */) {
|
|
13954
13956
|
const expCase = this._parseExpansionCase();
|
|
13955
13957
|
if (!expCase)
|
|
13956
13958
|
return; // error
|
|
13957
13959
|
cases.push(expCase);
|
|
13958
13960
|
}
|
|
13959
13961
|
// read the final }
|
|
13960
|
-
if (this._peek.type !== 23 /* EXPANSION_FORM_END */) {
|
|
13962
|
+
if (this._peek.type !== 23 /* TokenType.EXPANSION_FORM_END */) {
|
|
13961
13963
|
this.errors.push(TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '}'.`));
|
|
13962
13964
|
return;
|
|
13963
13965
|
}
|
|
@@ -13968,7 +13970,7 @@ class _TreeBuilder {
|
|
|
13968
13970
|
_parseExpansionCase() {
|
|
13969
13971
|
const value = this._advance();
|
|
13970
13972
|
// read {
|
|
13971
|
-
if (this._peek.type !== 21 /* EXPANSION_CASE_EXP_START */) {
|
|
13973
|
+
if (this._peek.type !== 21 /* TokenType.EXPANSION_CASE_EXP_START */) {
|
|
13972
13974
|
this.errors.push(TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '{'.`));
|
|
13973
13975
|
return null;
|
|
13974
13976
|
}
|
|
@@ -13978,7 +13980,7 @@ class _TreeBuilder {
|
|
|
13978
13980
|
if (!exp)
|
|
13979
13981
|
return null;
|
|
13980
13982
|
const end = this._advance();
|
|
13981
|
-
exp.push({ type: 24 /* EOF */, parts: [], sourceSpan: end.sourceSpan });
|
|
13983
|
+
exp.push({ type: 24 /* TokenType.EOF */, parts: [], sourceSpan: end.sourceSpan });
|
|
13982
13984
|
// parse everything in between { and }
|
|
13983
13985
|
const expansionCaseParser = new _TreeBuilder(exp, this.getTagDefinition);
|
|
13984
13986
|
expansionCaseParser.build();
|
|
@@ -13992,14 +13994,14 @@ class _TreeBuilder {
|
|
|
13992
13994
|
}
|
|
13993
13995
|
_collectExpansionExpTokens(start) {
|
|
13994
13996
|
const exp = [];
|
|
13995
|
-
const expansionFormStack = [21 /* EXPANSION_CASE_EXP_START */];
|
|
13997
|
+
const expansionFormStack = [21 /* TokenType.EXPANSION_CASE_EXP_START */];
|
|
13996
13998
|
while (true) {
|
|
13997
|
-
if (this._peek.type === 19 /* EXPANSION_FORM_START */ ||
|
|
13998
|
-
this._peek.type === 21 /* EXPANSION_CASE_EXP_START */) {
|
|
13999
|
+
if (this._peek.type === 19 /* TokenType.EXPANSION_FORM_START */ ||
|
|
14000
|
+
this._peek.type === 21 /* TokenType.EXPANSION_CASE_EXP_START */) {
|
|
13999
14001
|
expansionFormStack.push(this._peek.type);
|
|
14000
14002
|
}
|
|
14001
|
-
if (this._peek.type === 22 /* EXPANSION_CASE_EXP_END */) {
|
|
14002
|
-
if (lastOnStack(expansionFormStack, 21 /* EXPANSION_CASE_EXP_START */)) {
|
|
14003
|
+
if (this._peek.type === 22 /* TokenType.EXPANSION_CASE_EXP_END */) {
|
|
14004
|
+
if (lastOnStack(expansionFormStack, 21 /* TokenType.EXPANSION_CASE_EXP_START */)) {
|
|
14003
14005
|
expansionFormStack.pop();
|
|
14004
14006
|
if (expansionFormStack.length === 0)
|
|
14005
14007
|
return exp;
|
|
@@ -14009,8 +14011,8 @@ class _TreeBuilder {
|
|
|
14009
14011
|
return null;
|
|
14010
14012
|
}
|
|
14011
14013
|
}
|
|
14012
|
-
if (this._peek.type === 23 /* EXPANSION_FORM_END */) {
|
|
14013
|
-
if (lastOnStack(expansionFormStack, 19 /* EXPANSION_FORM_START */)) {
|
|
14014
|
+
if (this._peek.type === 23 /* TokenType.EXPANSION_FORM_END */) {
|
|
14015
|
+
if (lastOnStack(expansionFormStack, 19 /* TokenType.EXPANSION_FORM_START */)) {
|
|
14014
14016
|
expansionFormStack.pop();
|
|
14015
14017
|
}
|
|
14016
14018
|
else {
|
|
@@ -14018,7 +14020,7 @@ class _TreeBuilder {
|
|
|
14018
14020
|
return null;
|
|
14019
14021
|
}
|
|
14020
14022
|
}
|
|
14021
|
-
if (this._peek.type === 24 /* EOF */) {
|
|
14023
|
+
if (this._peek.type === 24 /* TokenType.EOF */) {
|
|
14022
14024
|
this.errors.push(TreeError.create(null, start.sourceSpan, `Invalid ICU message. Missing '}'.`));
|
|
14023
14025
|
return null;
|
|
14024
14026
|
}
|
|
@@ -14037,18 +14039,18 @@ class _TreeBuilder {
|
|
|
14037
14039
|
tokens[0] = { type: token.type, sourceSpan: token.sourceSpan, parts: [text] };
|
|
14038
14040
|
}
|
|
14039
14041
|
}
|
|
14040
|
-
while (this._peek.type === 8 /* INTERPOLATION */ || this._peek.type === 5 /* TEXT */ ||
|
|
14041
|
-
this._peek.type === 9 /* ENCODED_ENTITY */) {
|
|
14042
|
+
while (this._peek.type === 8 /* TokenType.INTERPOLATION */ || this._peek.type === 5 /* TokenType.TEXT */ ||
|
|
14043
|
+
this._peek.type === 9 /* TokenType.ENCODED_ENTITY */) {
|
|
14042
14044
|
token = this._advance();
|
|
14043
14045
|
tokens.push(token);
|
|
14044
|
-
if (token.type === 8 /* INTERPOLATION */) {
|
|
14046
|
+
if (token.type === 8 /* TokenType.INTERPOLATION */) {
|
|
14045
14047
|
// For backward compatibility we decode HTML entities that appear in interpolation
|
|
14046
14048
|
// expressions. This is arguably a bug, but it could be a considerable breaking change to
|
|
14047
14049
|
// fix it. It should be addressed in a larger project to refactor the entire parser/lexer
|
|
14048
14050
|
// chain after View Engine has been removed.
|
|
14049
14051
|
text += token.parts.join('').replace(/&([^;]+);/g, decodeEntity);
|
|
14050
14052
|
}
|
|
14051
|
-
else if (token.type === 9 /* ENCODED_ENTITY */) {
|
|
14053
|
+
else if (token.type === 9 /* TokenType.ENCODED_ENTITY */) {
|
|
14052
14054
|
text += token.parts[0];
|
|
14053
14055
|
}
|
|
14054
14056
|
else {
|
|
@@ -14069,14 +14071,14 @@ class _TreeBuilder {
|
|
|
14069
14071
|
_consumeStartTag(startTagToken) {
|
|
14070
14072
|
const [prefix, name] = startTagToken.parts;
|
|
14071
14073
|
const attrs = [];
|
|
14072
|
-
while (this._peek.type === 14 /* ATTR_NAME */) {
|
|
14074
|
+
while (this._peek.type === 14 /* TokenType.ATTR_NAME */) {
|
|
14073
14075
|
attrs.push(this._consumeAttr(this._advance()));
|
|
14074
14076
|
}
|
|
14075
14077
|
const fullName = this._getElementFullName(prefix, name, this._getParentElement());
|
|
14076
14078
|
let selfClosing = false;
|
|
14077
14079
|
// Note: There could have been a tokenizer error
|
|
14078
14080
|
// so that we don't get a token for the end tag...
|
|
14079
|
-
if (this._peek.type === 2 /* TAG_OPEN_END_VOID */) {
|
|
14081
|
+
if (this._peek.type === 2 /* TokenType.TAG_OPEN_END_VOID */) {
|
|
14080
14082
|
this._advance();
|
|
14081
14083
|
selfClosing = true;
|
|
14082
14084
|
const tagDef = this.getTagDefinition(fullName);
|
|
@@ -14084,7 +14086,7 @@ class _TreeBuilder {
|
|
|
14084
14086
|
this.errors.push(TreeError.create(fullName, startTagToken.sourceSpan, `Only void and foreign elements can be self closed "${startTagToken.parts[1]}"`));
|
|
14085
14087
|
}
|
|
14086
14088
|
}
|
|
14087
|
-
else if (this._peek.type === 1 /* TAG_OPEN_END */) {
|
|
14089
|
+
else if (this._peek.type === 1 /* TokenType.TAG_OPEN_END */) {
|
|
14088
14090
|
this._advance();
|
|
14089
14091
|
selfClosing = false;
|
|
14090
14092
|
}
|
|
@@ -14099,7 +14101,7 @@ class _TreeBuilder {
|
|
|
14099
14101
|
// element start tag also represents the end tag.
|
|
14100
14102
|
this._popElement(fullName, span);
|
|
14101
14103
|
}
|
|
14102
|
-
else if (startTagToken.type === 4 /* INCOMPLETE_TAG_OPEN */) {
|
|
14104
|
+
else if (startTagToken.type === 4 /* TokenType.INCOMPLETE_TAG_OPEN */) {
|
|
14103
14105
|
// We already know the opening tag is not complete, so it is unlikely it has a corresponding
|
|
14104
14106
|
// close tag. Let's optimistically parse it as a full element and emit an error.
|
|
14105
14107
|
this._popElement(fullName, null);
|
|
@@ -14156,7 +14158,7 @@ class _TreeBuilder {
|
|
|
14156
14158
|
const fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);
|
|
14157
14159
|
let attrEnd = attrName.sourceSpan.end;
|
|
14158
14160
|
// Consume any quote
|
|
14159
|
-
if (this._peek.type === 15 /* ATTR_QUOTE */) {
|
|
14161
|
+
if (this._peek.type === 15 /* TokenType.ATTR_QUOTE */) {
|
|
14160
14162
|
this._advance();
|
|
14161
14163
|
}
|
|
14162
14164
|
// Consume the attribute value
|
|
@@ -14169,22 +14171,22 @@ class _TreeBuilder {
|
|
|
14169
14171
|
// being able to consider `ATTR_VALUE_INTERPOLATION` as an option. This is because TS is not
|
|
14170
14172
|
// able to see that `_advance()` will actually mutate `_peek`.
|
|
14171
14173
|
const nextTokenType = this._peek.type;
|
|
14172
|
-
if (nextTokenType === 16 /* ATTR_VALUE_TEXT */) {
|
|
14174
|
+
if (nextTokenType === 16 /* TokenType.ATTR_VALUE_TEXT */) {
|
|
14173
14175
|
valueStartSpan = this._peek.sourceSpan;
|
|
14174
14176
|
valueEnd = this._peek.sourceSpan.end;
|
|
14175
|
-
while (this._peek.type === 16 /* ATTR_VALUE_TEXT */ ||
|
|
14176
|
-
this._peek.type === 17 /* ATTR_VALUE_INTERPOLATION */ ||
|
|
14177
|
-
this._peek.type === 9 /* ENCODED_ENTITY */) {
|
|
14177
|
+
while (this._peek.type === 16 /* TokenType.ATTR_VALUE_TEXT */ ||
|
|
14178
|
+
this._peek.type === 17 /* TokenType.ATTR_VALUE_INTERPOLATION */ ||
|
|
14179
|
+
this._peek.type === 9 /* TokenType.ENCODED_ENTITY */) {
|
|
14178
14180
|
const valueToken = this._advance();
|
|
14179
14181
|
valueTokens.push(valueToken);
|
|
14180
|
-
if (valueToken.type === 17 /* ATTR_VALUE_INTERPOLATION */) {
|
|
14182
|
+
if (valueToken.type === 17 /* TokenType.ATTR_VALUE_INTERPOLATION */) {
|
|
14181
14183
|
// For backward compatibility we decode HTML entities that appear in interpolation
|
|
14182
14184
|
// expressions. This is arguably a bug, but it could be a considerable breaking change to
|
|
14183
14185
|
// fix it. It should be addressed in a larger project to refactor the entire parser/lexer
|
|
14184
14186
|
// chain after View Engine has been removed.
|
|
14185
14187
|
value += valueToken.parts.join('').replace(/&([^;]+);/g, decodeEntity);
|
|
14186
14188
|
}
|
|
14187
|
-
else if (valueToken.type === 9 /* ENCODED_ENTITY */) {
|
|
14189
|
+
else if (valueToken.type === 9 /* TokenType.ENCODED_ENTITY */) {
|
|
14188
14190
|
value += valueToken.parts[0];
|
|
14189
14191
|
}
|
|
14190
14192
|
else {
|
|
@@ -14194,7 +14196,7 @@ class _TreeBuilder {
|
|
|
14194
14196
|
}
|
|
14195
14197
|
}
|
|
14196
14198
|
// Consume any quote
|
|
14197
|
-
if (this._peek.type === 15 /* ATTR_QUOTE */) {
|
|
14199
|
+
if (this._peek.type === 15 /* TokenType.ATTR_QUOTE */) {
|
|
14198
14200
|
const quoteToken = this._advance();
|
|
14199
14201
|
attrEnd = quoteToken.sourceSpan.end;
|
|
14200
14202
|
}
|
|
@@ -14324,7 +14326,7 @@ class WhitespaceVisitor {
|
|
|
14324
14326
|
(context.prev instanceof Expansion || context.next instanceof Expansion);
|
|
14325
14327
|
if (isNotBlank || hasExpansionSibling) {
|
|
14326
14328
|
// Process the whitespace in the tokens of this Text node
|
|
14327
|
-
const tokens = text.tokens.map(token => token.type === 5 /* TEXT */ ? createWhitespaceProcessedTextToken(token) : token);
|
|
14329
|
+
const tokens = text.tokens.map(token => token.type === 5 /* TokenType.TEXT */ ? createWhitespaceProcessedTextToken(token) : token);
|
|
14328
14330
|
// Process the whitespace of the value of this Text node
|
|
14329
14331
|
const value = processWhitespace(text.value);
|
|
14330
14332
|
return new Text(value, text.sourceSpan, tokens, text.i18n);
|
|
@@ -15151,7 +15153,7 @@ class BindingParser {
|
|
|
15151
15153
|
}
|
|
15152
15154
|
createBoundElementProperty(elementSelector, boundProp, skipValidation = false, mapPropertyName = true) {
|
|
15153
15155
|
if (boundProp.isAnimation) {
|
|
15154
|
-
return new BoundElementProperty(boundProp.name, 4 /* Animation */, SecurityContext.NONE, boundProp.expression, null, boundProp.sourceSpan, boundProp.keySpan, boundProp.valueSpan);
|
|
15156
|
+
return new BoundElementProperty(boundProp.name, 4 /* BindingType.Animation */, SecurityContext.NONE, boundProp.expression, null, boundProp.sourceSpan, boundProp.keySpan, boundProp.valueSpan);
|
|
15155
15157
|
}
|
|
15156
15158
|
let unit = null;
|
|
15157
15159
|
let bindingType = undefined;
|
|
@@ -15172,17 +15174,17 @@ class BindingParser {
|
|
|
15172
15174
|
const name = boundPropertyName.substring(nsSeparatorIdx + 1);
|
|
15173
15175
|
boundPropertyName = mergeNsAndName(ns, name);
|
|
15174
15176
|
}
|
|
15175
|
-
bindingType = 1 /* Attribute */;
|
|
15177
|
+
bindingType = 1 /* BindingType.Attribute */;
|
|
15176
15178
|
}
|
|
15177
15179
|
else if (parts[0] == CLASS_PREFIX) {
|
|
15178
15180
|
boundPropertyName = parts[1];
|
|
15179
|
-
bindingType = 2 /* Class */;
|
|
15181
|
+
bindingType = 2 /* BindingType.Class */;
|
|
15180
15182
|
securityContexts = [SecurityContext.NONE];
|
|
15181
15183
|
}
|
|
15182
15184
|
else if (parts[0] == STYLE_PREFIX) {
|
|
15183
15185
|
unit = parts.length > 2 ? parts[2] : null;
|
|
15184
15186
|
boundPropertyName = parts[1];
|
|
15185
|
-
bindingType = 3 /* Style */;
|
|
15187
|
+
bindingType = 3 /* BindingType.Style */;
|
|
15186
15188
|
securityContexts = [SecurityContext.STYLE];
|
|
15187
15189
|
}
|
|
15188
15190
|
}
|
|
@@ -15191,7 +15193,7 @@ class BindingParser {
|
|
|
15191
15193
|
const mappedPropName = this._schemaRegistry.getMappedPropName(boundProp.name);
|
|
15192
15194
|
boundPropertyName = mapPropertyName ? mappedPropName : boundProp.name;
|
|
15193
15195
|
securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, mappedPropName, false);
|
|
15194
|
-
bindingType = 0 /* Property */;
|
|
15196
|
+
bindingType = 0 /* BindingType.Property */;
|
|
15195
15197
|
if (!skipValidation) {
|
|
15196
15198
|
this._validatePropertyOrAttributeName(mappedPropName, boundProp.sourceSpan, false);
|
|
15197
15199
|
}
|
|
@@ -15204,7 +15206,7 @@ class BindingParser {
|
|
|
15204
15206
|
this._reportError(`Event name is missing in binding`, sourceSpan);
|
|
15205
15207
|
}
|
|
15206
15208
|
if (isAnimationLabel(name)) {
|
|
15207
|
-
name = name.
|
|
15209
|
+
name = name.slice(1);
|
|
15208
15210
|
if (keySpan !== undefined) {
|
|
15209
15211
|
keySpan = moveParseSourceSpan(keySpan, new AbsoluteSourceSpan(keySpan.start.offset + 1, keySpan.end.offset));
|
|
15210
15212
|
}
|
|
@@ -15223,7 +15225,7 @@ class BindingParser {
|
|
|
15223
15225
|
const eventName = matches[0];
|
|
15224
15226
|
const phase = matches[1].toLowerCase();
|
|
15225
15227
|
const ast = this._parseAction(expression, isAssignmentEvent, handlerSpan);
|
|
15226
|
-
targetEvents.push(new ParsedEvent(eventName, phase, 1 /* Animation */, ast, sourceSpan, handlerSpan, keySpan));
|
|
15228
|
+
targetEvents.push(new ParsedEvent(eventName, phase, 1 /* ParsedEventType.Animation */, ast, sourceSpan, handlerSpan, keySpan));
|
|
15227
15229
|
if (eventName.length === 0) {
|
|
15228
15230
|
this._reportError(`Animation event name is missing in binding`, sourceSpan);
|
|
15229
15231
|
}
|
|
@@ -15241,7 +15243,7 @@ class BindingParser {
|
|
|
15241
15243
|
const [target, eventName] = splitAtColon(name, [null, name]);
|
|
15242
15244
|
const ast = this._parseAction(expression, isAssignmentEvent, handlerSpan);
|
|
15243
15245
|
targetMatchableAttrs.push([name, ast.source]);
|
|
15244
|
-
targetEvents.push(new ParsedEvent(eventName, target, 0 /* Regular */, ast, sourceSpan, handlerSpan, keySpan));
|
|
15246
|
+
targetEvents.push(new ParsedEvent(eventName, target, 0 /* ParsedEventType.Regular */, ast, sourceSpan, handlerSpan, keySpan));
|
|
15245
15247
|
// Don't detect directives for event names for now,
|
|
15246
15248
|
// so don't add the event name to the matchableAttrs
|
|
15247
15249
|
}
|
|
@@ -16311,8 +16313,8 @@ class _I18nVisitor {
|
|
|
16311
16313
|
let hasInterpolation = false;
|
|
16312
16314
|
for (const token of tokens) {
|
|
16313
16315
|
switch (token.type) {
|
|
16314
|
-
case 8 /* INTERPOLATION */:
|
|
16315
|
-
case 17 /* ATTR_VALUE_INTERPOLATION */:
|
|
16316
|
+
case 8 /* TokenType.INTERPOLATION */:
|
|
16317
|
+
case 17 /* TokenType.ATTR_VALUE_INTERPOLATION */:
|
|
16316
16318
|
hasInterpolation = true;
|
|
16317
16319
|
const expression = token.parts[1];
|
|
16318
16320
|
const baseName = extractPlaceholderName(expression) || 'INTERPOLATION';
|
|
@@ -16641,25 +16643,78 @@ function parseI18nMeta(meta = '') {
|
|
|
16641
16643
|
function i18nMetaToJSDoc(meta) {
|
|
16642
16644
|
const tags = [];
|
|
16643
16645
|
if (meta.description) {
|
|
16644
|
-
tags.push({ tagName: "desc" /* Desc */, text: meta.description });
|
|
16646
|
+
tags.push({ tagName: "desc" /* o.JSDocTagName.Desc */, text: meta.description });
|
|
16645
16647
|
}
|
|
16646
16648
|
else {
|
|
16647
16649
|
// Suppress the JSCompiler warning that a `@desc` was not given for this message.
|
|
16648
|
-
tags.push({ tagName: "suppress" /* Suppress */, text: '{msgDescriptions}' });
|
|
16650
|
+
tags.push({ tagName: "suppress" /* o.JSDocTagName.Suppress */, text: '{msgDescriptions}' });
|
|
16649
16651
|
}
|
|
16650
16652
|
if (meta.meaning) {
|
|
16651
|
-
tags.push({ tagName: "meaning" /* Meaning */, text: meta.meaning });
|
|
16653
|
+
tags.push({ tagName: "meaning" /* o.JSDocTagName.Meaning */, text: meta.meaning });
|
|
16652
16654
|
}
|
|
16653
16655
|
return jsDocComment(tags);
|
|
16654
16656
|
}
|
|
16655
16657
|
|
|
16656
16658
|
/** Closure uses `goog.getMsg(message)` to lookup translations */
|
|
16657
16659
|
const GOOG_GET_MSG = 'goog.getMsg';
|
|
16658
|
-
|
|
16660
|
+
/**
|
|
16661
|
+
* Generates a `goog.getMsg()` statement and reassignment. The template:
|
|
16662
|
+
*
|
|
16663
|
+
* ```html
|
|
16664
|
+
* <div i18n>Sent from {{ sender }} to <span class="receiver">{{ receiver }}</span></div>
|
|
16665
|
+
* ```
|
|
16666
|
+
*
|
|
16667
|
+
* Generates:
|
|
16668
|
+
*
|
|
16669
|
+
* ```typescript
|
|
16670
|
+
* const MSG_FOO = goog.getMsg(
|
|
16671
|
+
* // Message template.
|
|
16672
|
+
* 'Sent from {$interpolation} to {$startTagSpan}{$interpolation_1}{$closeTagSpan}.',
|
|
16673
|
+
* // Placeholder values, set to magic strings which get replaced by the Angular runtime.
|
|
16674
|
+
* {
|
|
16675
|
+
* 'interpolation': '\uFFFD0\uFFFD',
|
|
16676
|
+
* 'startTagSpan': '\uFFFD1\uFFFD',
|
|
16677
|
+
* 'interpolation_1': '\uFFFD2\uFFFD',
|
|
16678
|
+
* 'closeTagSpan': '\uFFFD3\uFFFD',
|
|
16679
|
+
* },
|
|
16680
|
+
* // Options bag.
|
|
16681
|
+
* {
|
|
16682
|
+
* // Maps each placeholder to the original Angular source code which generates it's value.
|
|
16683
|
+
* original_code: {
|
|
16684
|
+
* 'interpolation': '{{ sender }}',
|
|
16685
|
+
* 'startTagSpan': '<span class="receiver">',
|
|
16686
|
+
* 'interploation_1': '{{ receiver }}',
|
|
16687
|
+
* 'closeTagSpan': '</span>',
|
|
16688
|
+
* },
|
|
16689
|
+
* },
|
|
16690
|
+
* );
|
|
16691
|
+
* const I18N_0 = MSG_FOO;
|
|
16692
|
+
* ```
|
|
16693
|
+
*/
|
|
16694
|
+
function createGoogleGetMsgStatements(variable$1, message, closureVar, placeholderValues) {
|
|
16659
16695
|
const messageString = serializeI18nMessageForGetMsg(message);
|
|
16660
16696
|
const args = [literal(messageString)];
|
|
16661
|
-
if (Object.keys(
|
|
16662
|
-
|
|
16697
|
+
if (Object.keys(placeholderValues).length) {
|
|
16698
|
+
// Message template parameters containing the magic strings replaced by the Angular runtime with
|
|
16699
|
+
// real data, e.g. `{'interpolation': '\uFFFD0\uFFFD'}`.
|
|
16700
|
+
args.push(mapLiteral(formatI18nPlaceholderNamesInMap(placeholderValues, true /* useCamelCase */), true /* quoted */));
|
|
16701
|
+
// Message options object, which contains original source code for placeholders (as they are
|
|
16702
|
+
// present in a template, e.g.
|
|
16703
|
+
// `{original_code: {'interpolation': '{{ name }}', 'startTagSpan': '<span>'}}`.
|
|
16704
|
+
args.push(mapLiteral({
|
|
16705
|
+
original_code: literalMap(Object.keys(placeholderValues)
|
|
16706
|
+
.map((param) => ({
|
|
16707
|
+
key: formatI18nPlaceholderName(param),
|
|
16708
|
+
quoted: true,
|
|
16709
|
+
value: message.placeholders[param] ?
|
|
16710
|
+
// Get source span for typical placeholder if it exists.
|
|
16711
|
+
literal(message.placeholders[param].sourceSpan.toString()) :
|
|
16712
|
+
// Otherwise must be an ICU expression, get it's source span.
|
|
16713
|
+
literal(message.placeholderToMessage[param]
|
|
16714
|
+
.nodes.map((node) => node.sourceSpan.toString())
|
|
16715
|
+
.join('')),
|
|
16716
|
+
}))),
|
|
16717
|
+
}));
|
|
16663
16718
|
}
|
|
16664
16719
|
// /**
|
|
16665
16720
|
// * @desc description of message
|
|
@@ -16849,14 +16904,28 @@ function prepareEventListenerParameters(eventAst, handlerName = null, scope = nu
|
|
|
16849
16904
|
scope.getOrCreateSharedContextVar(0);
|
|
16850
16905
|
const bindingStatements = convertActionBinding(scope, implicitReceiverExpr, handler, 'b', eventAst.handlerSpan, implicitReceiverAccesses, EVENT_BINDING_SCOPE_GLOBALS);
|
|
16851
16906
|
const statements = [];
|
|
16852
|
-
|
|
16907
|
+
const variableDeclarations = scope === null || scope === void 0 ? void 0 : scope.variableDeclarations();
|
|
16908
|
+
const restoreViewStatement = scope === null || scope === void 0 ? void 0 : scope.restoreViewStatement();
|
|
16909
|
+
if (variableDeclarations) {
|
|
16853
16910
|
// `variableDeclarations` needs to run first, because
|
|
16854
16911
|
// `restoreViewStatement` depends on the result.
|
|
16855
|
-
statements.push(...
|
|
16856
|
-
statements.unshift(...scope.restoreViewStatement());
|
|
16912
|
+
statements.push(...variableDeclarations);
|
|
16857
16913
|
}
|
|
16858
16914
|
statements.push(...bindingStatements);
|
|
16859
|
-
|
|
16915
|
+
if (restoreViewStatement) {
|
|
16916
|
+
statements.unshift(restoreViewStatement);
|
|
16917
|
+
// If there's a `restoreView` call, we need to reset the view at the end of the listener
|
|
16918
|
+
// in order to avoid a leak. If there's a `return` statement already, we wrap it in the
|
|
16919
|
+
// call, e.g. `return resetView(ctx.foo())`. Otherwise we add the call as the last statement.
|
|
16920
|
+
const lastStatement = statements[statements.length - 1];
|
|
16921
|
+
if (lastStatement instanceof ReturnStatement) {
|
|
16922
|
+
statements[statements.length - 1] = new ReturnStatement(invokeInstruction(lastStatement.value.sourceSpan, Identifiers.resetView, [lastStatement.value]));
|
|
16923
|
+
}
|
|
16924
|
+
else {
|
|
16925
|
+
statements.push(new ExpressionStatement(invokeInstruction(null, Identifiers.resetView, [])));
|
|
16926
|
+
}
|
|
16927
|
+
}
|
|
16928
|
+
const eventName = type === 1 /* ParsedEventType.Animation */ ? prepareSyntheticListenerName(name, phase) : name;
|
|
16860
16929
|
const fnName = handlerName && sanitizeIdentifier(handlerName);
|
|
16861
16930
|
const fnArgs = [];
|
|
16862
16931
|
if (implicitReceiverAccesses.has(eventArgumentName)) {
|
|
@@ -17008,10 +17077,10 @@ class TemplateDefinitionBuilder {
|
|
|
17008
17077
|
const creationVariables = this._bindingScope.viewSnapshotStatements();
|
|
17009
17078
|
const updateVariables = this._bindingScope.variableDeclarations().concat(this._tempVariables);
|
|
17010
17079
|
const creationBlock = creationStatements.length > 0 ?
|
|
17011
|
-
[renderFlagCheckIfStmt(1 /* Create */, creationVariables.concat(creationStatements))] :
|
|
17080
|
+
[renderFlagCheckIfStmt(1 /* core.RenderFlags.Create */, creationVariables.concat(creationStatements))] :
|
|
17012
17081
|
[];
|
|
17013
17082
|
const updateBlock = updateStatements.length > 0 ?
|
|
17014
|
-
[renderFlagCheckIfStmt(2 /* Update */, updateVariables.concat(updateStatements))] :
|
|
17083
|
+
[renderFlagCheckIfStmt(2 /* core.RenderFlags.Update */, updateVariables.concat(updateStatements))] :
|
|
17015
17084
|
[];
|
|
17016
17085
|
return fn(
|
|
17017
17086
|
// i.e. (rf: RenderFlags, ctx: any)
|
|
@@ -17049,7 +17118,7 @@ class TemplateDefinitionBuilder {
|
|
|
17049
17118
|
const scopedName = this._bindingScope.freshReferenceName();
|
|
17050
17119
|
const retrievalLevel = this.level;
|
|
17051
17120
|
const lhs = variable(variable$1.name + scopedName);
|
|
17052
|
-
this._bindingScope.set(retrievalLevel, variable$1.name, lhs, 1 /* CONTEXT */, (scope, relativeLevel) => {
|
|
17121
|
+
this._bindingScope.set(retrievalLevel, variable$1.name, lhs, 1 /* DeclarationPriority.CONTEXT */, (scope, relativeLevel) => {
|
|
17053
17122
|
let rhs;
|
|
17054
17123
|
if (scope.bindingLevel === retrievalLevel) {
|
|
17055
17124
|
if (scope.isListenerScope() && scope.hasRestoreViewVariable()) {
|
|
@@ -17303,7 +17372,7 @@ class TemplateDefinitionBuilder {
|
|
|
17303
17372
|
element.inputs.forEach(input => {
|
|
17304
17373
|
const stylingInputWasSet = stylingBuilder.registerBoundInput(input);
|
|
17305
17374
|
if (!stylingInputWasSet) {
|
|
17306
|
-
if (input.type === 0 /* Property */ && input.i18n) {
|
|
17375
|
+
if (input.type === 0 /* BindingType.Property */ && input.i18n) {
|
|
17307
17376
|
boundI18nAttrs.push(input);
|
|
17308
17377
|
}
|
|
17309
17378
|
else {
|
|
@@ -17376,7 +17445,7 @@ class TemplateDefinitionBuilder {
|
|
|
17376
17445
|
// Generate element input bindings
|
|
17377
17446
|
allOtherInputs.forEach(input => {
|
|
17378
17447
|
const inputType = input.type;
|
|
17379
|
-
if (inputType === 4 /* Animation */) {
|
|
17448
|
+
if (inputType === 4 /* BindingType.Animation */) {
|
|
17380
17449
|
const value = input.value.visit(this._valueConverter);
|
|
17381
17450
|
// animation bindings can be presented in the following formats:
|
|
17382
17451
|
// 1. [@binding]="fooExp"
|
|
@@ -17403,7 +17472,7 @@ class TemplateDefinitionBuilder {
|
|
|
17403
17472
|
if (value !== undefined) {
|
|
17404
17473
|
const params = [];
|
|
17405
17474
|
const [attrNamespace, attrName] = splitNsName(input.name);
|
|
17406
|
-
const isAttributeBinding = inputType === 1 /* Attribute */;
|
|
17475
|
+
const isAttributeBinding = inputType === 1 /* BindingType.Attribute */;
|
|
17407
17476
|
const sanitizationRef = resolveSanitizationFn(input.securityContext, isAttributeBinding);
|
|
17408
17477
|
if (sanitizationRef)
|
|
17409
17478
|
params.push(sanitizationRef);
|
|
@@ -17419,7 +17488,7 @@ class TemplateDefinitionBuilder {
|
|
|
17419
17488
|
}
|
|
17420
17489
|
}
|
|
17421
17490
|
this.allocateBindingSlots(value);
|
|
17422
|
-
if (inputType === 0 /* Property */) {
|
|
17491
|
+
if (inputType === 0 /* BindingType.Property */) {
|
|
17423
17492
|
if (value instanceof Interpolation) {
|
|
17424
17493
|
// prop="{{value}}" and friends
|
|
17425
17494
|
this.interpolatedUpdateInstruction(getPropertyInterpolationExpression(value), elementIndex, attrName, input, value, params);
|
|
@@ -17433,7 +17502,7 @@ class TemplateDefinitionBuilder {
|
|
|
17433
17502
|
});
|
|
17434
17503
|
}
|
|
17435
17504
|
}
|
|
17436
|
-
else if (inputType === 1 /* Attribute */) {
|
|
17505
|
+
else if (inputType === 1 /* BindingType.Attribute */) {
|
|
17437
17506
|
if (value instanceof Interpolation && getInterpolationArgsLength(value) > 1) {
|
|
17438
17507
|
// attr.name="text{{value}}" and friends
|
|
17439
17508
|
this.interpolatedUpdateInstruction(getAttributeInterpolationExpression(value), elementIndex, attrName, input, value, params);
|
|
@@ -17599,7 +17668,7 @@ class TemplateDefinitionBuilder {
|
|
|
17599
17668
|
// - all ICU vars (such as `VAR_SELECT` or `VAR_PLURAL`) are replaced with correct values
|
|
17600
17669
|
const transformFn = (raw) => {
|
|
17601
17670
|
const params = Object.assign(Object.assign({}, vars), placeholders);
|
|
17602
|
-
const formatted =
|
|
17671
|
+
const formatted = formatI18nPlaceholderNamesInMap(params, /* useCamelCase */ false);
|
|
17603
17672
|
return invokeInstruction(null, Identifiers.i18nPostprocess, [raw, mapLiteral(formatted, true)]);
|
|
17604
17673
|
};
|
|
17605
17674
|
// in case the whole i18n message is a single ICU - we do not need to
|
|
@@ -17830,13 +17899,13 @@ class TemplateDefinitionBuilder {
|
|
|
17830
17899
|
const input = inputs[i];
|
|
17831
17900
|
// We don't want the animation and attribute bindings in the
|
|
17832
17901
|
// attributes array since they aren't used for directive matching.
|
|
17833
|
-
if (input.type !== 4 /* Animation */ && input.type !== 1 /* Attribute */) {
|
|
17902
|
+
if (input.type !== 4 /* BindingType.Animation */ && input.type !== 1 /* BindingType.Attribute */) {
|
|
17834
17903
|
addAttrExpr(input.name);
|
|
17835
17904
|
}
|
|
17836
17905
|
}
|
|
17837
17906
|
for (let i = 0; i < outputs.length; i++) {
|
|
17838
17907
|
const output = outputs[i];
|
|
17839
|
-
if (output.type !== 1 /* Animation */) {
|
|
17908
|
+
if (output.type !== 1 /* ParsedEventType.Animation */) {
|
|
17840
17909
|
addAttrExpr(output.name);
|
|
17841
17910
|
}
|
|
17842
17911
|
}
|
|
@@ -17845,15 +17914,15 @@ class TemplateDefinitionBuilder {
|
|
|
17845
17914
|
// to the expressions. The marker is important because it tells the runtime
|
|
17846
17915
|
// code that this is where attributes without values start...
|
|
17847
17916
|
if (attrExprs.length !== attrsLengthBeforeInputs) {
|
|
17848
|
-
attrExprs.splice(attrsLengthBeforeInputs, 0, literal(3 /* Bindings */));
|
|
17917
|
+
attrExprs.splice(attrsLengthBeforeInputs, 0, literal(3 /* core.AttributeMarker.Bindings */));
|
|
17849
17918
|
}
|
|
17850
17919
|
}
|
|
17851
17920
|
if (templateAttrs.length) {
|
|
17852
|
-
attrExprs.push(literal(4 /* Template */));
|
|
17921
|
+
attrExprs.push(literal(4 /* core.AttributeMarker.Template */));
|
|
17853
17922
|
templateAttrs.forEach(attr => addAttrExpr(attr.name));
|
|
17854
17923
|
}
|
|
17855
17924
|
if (boundI18nAttrs.length) {
|
|
17856
|
-
attrExprs.push(literal(6 /* I18n */));
|
|
17925
|
+
attrExprs.push(literal(6 /* core.AttributeMarker.I18n */));
|
|
17857
17926
|
boundI18nAttrs.forEach(attr => addAttrExpr(attr.name));
|
|
17858
17927
|
}
|
|
17859
17928
|
return attrExprs;
|
|
@@ -17884,7 +17953,7 @@ class TemplateDefinitionBuilder {
|
|
|
17884
17953
|
const variableName = this._bindingScope.freshReferenceName();
|
|
17885
17954
|
const retrievalLevel = this.level;
|
|
17886
17955
|
const lhs = variable(variableName);
|
|
17887
|
-
this._bindingScope.set(retrievalLevel, reference.name, lhs, 0 /* DEFAULT */, (scope, relativeLevel) => {
|
|
17956
|
+
this._bindingScope.set(retrievalLevel, reference.name, lhs, 0 /* DeclarationPriority.DEFAULT */, (scope, relativeLevel) => {
|
|
17888
17957
|
// e.g. nextContext(2);
|
|
17889
17958
|
const nextContextStmt = relativeLevel > 0 ? [generateNextContextExpr(relativeLevel).toStmt()] : [];
|
|
17890
17959
|
// e.g. const $foo$ = reference(1);
|
|
@@ -17898,7 +17967,7 @@ class TemplateDefinitionBuilder {
|
|
|
17898
17967
|
prepareListenerParameter(tagName, outputAst, index) {
|
|
17899
17968
|
return () => {
|
|
17900
17969
|
const eventName = outputAst.name;
|
|
17901
|
-
const bindingFnName = outputAst.type === 1 /* Animation */ ?
|
|
17970
|
+
const bindingFnName = outputAst.type === 1 /* ParsedEventType.Animation */ ?
|
|
17902
17971
|
// synthetic @listener.foo values are treated the exact same as are standard listeners
|
|
17903
17972
|
prepareSyntheticListenerFunctionName(eventName, outputAst.phase) :
|
|
17904
17973
|
sanitizeIdentifier(eventName);
|
|
@@ -18018,7 +18087,7 @@ function getAttributeNameLiterals(name) {
|
|
|
18018
18087
|
const nameLiteral = literal(attributeName);
|
|
18019
18088
|
if (attributeNamespace) {
|
|
18020
18089
|
return [
|
|
18021
|
-
literal(0 /* NamespaceURI */), literal(attributeNamespace), nameLiteral
|
|
18090
|
+
literal(0 /* core.AttributeMarker.NamespaceURI */), literal(attributeNamespace), nameLiteral
|
|
18022
18091
|
];
|
|
18023
18092
|
}
|
|
18024
18093
|
return [nameLiteral];
|
|
@@ -18087,7 +18156,7 @@ class BindingScope {
|
|
|
18087
18156
|
* @param declareLocalCallback The callback to invoke when declaring this local var
|
|
18088
18157
|
* @param localRef Whether or not this is a local ref
|
|
18089
18158
|
*/
|
|
18090
|
-
set(retrievalLevel, name, lhs, priority = 0 /* DEFAULT */, declareLocalCallback, localRef) {
|
|
18159
|
+
set(retrievalLevel, name, lhs, priority = 0 /* DeclarationPriority.DEFAULT */, declareLocalCallback, localRef) {
|
|
18091
18160
|
if (this.map.has(name)) {
|
|
18092
18161
|
if (localRef) {
|
|
18093
18162
|
// Do not throw an error if it's a local ref and do not update existing value,
|
|
@@ -18143,7 +18212,7 @@ class BindingScope {
|
|
|
18143
18212
|
return sharedCtxObj && sharedCtxObj.declare ? sharedCtxObj.lhs : null;
|
|
18144
18213
|
}
|
|
18145
18214
|
maybeGenerateSharedContextVar(value) {
|
|
18146
|
-
if (value.priority === 1 /* CONTEXT */ &&
|
|
18215
|
+
if (value.priority === 1 /* DeclarationPriority.CONTEXT */ &&
|
|
18147
18216
|
value.retrievalLevel < this.bindingLevel) {
|
|
18148
18217
|
const sharedCtxObj = this.map.get(SHARED_CONTEXT_KEY + value.retrievalLevel);
|
|
18149
18218
|
if (sharedCtxObj) {
|
|
@@ -18164,7 +18233,7 @@ class BindingScope {
|
|
|
18164
18233
|
return [lhs.set(generateNextContextExpr(relativeLevel)).toConstDecl()];
|
|
18165
18234
|
},
|
|
18166
18235
|
declare: false,
|
|
18167
|
-
priority: 2 /* SHARED_CONTEXT */,
|
|
18236
|
+
priority: 2 /* DeclarationPriority.SHARED_CONTEXT */,
|
|
18168
18237
|
});
|
|
18169
18238
|
}
|
|
18170
18239
|
getComponentProperty(name) {
|
|
@@ -18187,16 +18256,15 @@ class BindingScope {
|
|
|
18187
18256
|
}
|
|
18188
18257
|
}
|
|
18189
18258
|
restoreViewStatement() {
|
|
18190
|
-
const statements = [];
|
|
18191
18259
|
if (this.restoreViewVariable) {
|
|
18192
18260
|
const restoreCall = invokeInstruction(null, Identifiers.restoreView, [this.restoreViewVariable]);
|
|
18193
18261
|
// Either `const restoredCtx = restoreView($state$);` or `restoreView($state$);`
|
|
18194
18262
|
// depending on whether it is being used.
|
|
18195
|
-
|
|
18263
|
+
return this.usesRestoredViewContext ?
|
|
18196
18264
|
variable(RESTORED_VIEW_CONTEXT_NAME).set(restoreCall).toConstDecl() :
|
|
18197
|
-
restoreCall.toStmt()
|
|
18265
|
+
restoreCall.toStmt();
|
|
18198
18266
|
}
|
|
18199
|
-
return
|
|
18267
|
+
return null;
|
|
18200
18268
|
}
|
|
18201
18269
|
viewSnapshotStatements() {
|
|
18202
18270
|
// const $state$ = getCurrentView();
|
|
@@ -18262,7 +18330,7 @@ function getNgProjectAsLiteral(attribute) {
|
|
|
18262
18330
|
// Parse the attribute value into a CssSelectorList. Note that we only take the
|
|
18263
18331
|
// first selector, because we don't support multiple selectors in ngProjectAs.
|
|
18264
18332
|
const parsedR3Selector = parseSelectorToR3Selector(attribute.value)[0];
|
|
18265
|
-
return [literal(5 /* ProjectAs */), asLiteral(parsedR3Selector)];
|
|
18333
|
+
return [literal(5 /* core.AttributeMarker.ProjectAs */), asLiteral(parsedR3Selector)];
|
|
18266
18334
|
}
|
|
18267
18335
|
/**
|
|
18268
18336
|
* Gets the instruction to generate for an interpolated property
|
|
@@ -18521,7 +18589,7 @@ const NG_I18N_CLOSURE_MODE = 'ngI18nClosureMode';
|
|
|
18521
18589
|
function getTranslationDeclStmts(message, variable, closureVar, params = {}, transformFn) {
|
|
18522
18590
|
const statements = [
|
|
18523
18591
|
declareI18nVariable(variable),
|
|
18524
|
-
ifStmt(createClosureModeGuard(), createGoogleGetMsgStatements(variable, message, closureVar,
|
|
18592
|
+
ifStmt(createClosureModeGuard(), createGoogleGetMsgStatements(variable, message, closureVar, params), createLocalizeStatements(variable, message, formatI18nPlaceholderNamesInMap(params, /* useCamelCase */ false))),
|
|
18525
18593
|
];
|
|
18526
18594
|
if (transformFn) {
|
|
18527
18595
|
statements.push(new ExpressionStatement(variable.set(transformFn(variable))));
|
|
@@ -18586,6 +18654,9 @@ function baseDirectiveFields(meta, constantPool, bindingParser) {
|
|
|
18586
18654
|
if (meta.exportAs !== null) {
|
|
18587
18655
|
definitionMap.set('exportAs', literalArr(meta.exportAs.map(e => literal(e))));
|
|
18588
18656
|
}
|
|
18657
|
+
if (meta.isStandalone) {
|
|
18658
|
+
definitionMap.set('standalone', literal(true));
|
|
18659
|
+
}
|
|
18589
18660
|
return definitionMap;
|
|
18590
18661
|
}
|
|
18591
18662
|
/**
|
|
@@ -18612,6 +18683,10 @@ function addFeatures(definitionMap, meta) {
|
|
|
18612
18683
|
if (meta.lifecycle.usesOnChanges) {
|
|
18613
18684
|
features.push(importExpr(Identifiers.NgOnChangesFeature));
|
|
18614
18685
|
}
|
|
18686
|
+
// TODO: better way of differentiating component vs directive metadata.
|
|
18687
|
+
if (meta.hasOwnProperty('template') && meta.isStandalone) {
|
|
18688
|
+
features.push(importExpr(Identifiers.StandaloneFeature));
|
|
18689
|
+
}
|
|
18615
18690
|
if (features.length) {
|
|
18616
18691
|
definitionMap.set('features', literalArr(features));
|
|
18617
18692
|
}
|
|
@@ -18675,17 +18750,8 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
18675
18750
|
definitionMap.set('consts', constsExpr);
|
|
18676
18751
|
}
|
|
18677
18752
|
definitionMap.set('template', templateFunctionExpression);
|
|
18678
|
-
|
|
18679
|
-
|
|
18680
|
-
const directivesList = literalArr(meta.directives.map(dir => dir.type));
|
|
18681
|
-
const directivesExpr = compileDeclarationList(directivesList, meta.declarationListEmitMode);
|
|
18682
|
-
definitionMap.set('directives', directivesExpr);
|
|
18683
|
-
}
|
|
18684
|
-
// e.g. `pipes: [MyPipe]`
|
|
18685
|
-
if (meta.pipes.size > 0) {
|
|
18686
|
-
const pipesList = literalArr(Array.from(meta.pipes.values()));
|
|
18687
|
-
const pipesExpr = compileDeclarationList(pipesList, meta.declarationListEmitMode);
|
|
18688
|
-
definitionMap.set('pipes', pipesExpr);
|
|
18753
|
+
if (meta.declarations.length > 0) {
|
|
18754
|
+
definitionMap.set('dependencies', compileDeclarationList(literalArr(meta.declarations.map(decl => decl.type)), meta.declarationListEmitMode));
|
|
18689
18755
|
}
|
|
18690
18756
|
if (meta.encapsulation === null) {
|
|
18691
18757
|
meta.encapsulation = exports.ViewEncapsulation.Emulated;
|
|
@@ -18695,8 +18761,15 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
18695
18761
|
const styleValues = meta.encapsulation == exports.ViewEncapsulation.Emulated ?
|
|
18696
18762
|
compileStyles(meta.styles, CONTENT_ATTR, HOST_ATTR) :
|
|
18697
18763
|
meta.styles;
|
|
18698
|
-
const
|
|
18699
|
-
|
|
18764
|
+
const styleNodes = styleValues.reduce((result, style) => {
|
|
18765
|
+
if (style.trim().length > 0) {
|
|
18766
|
+
result.push(constantPool.getConstLiteral(literal(style)));
|
|
18767
|
+
}
|
|
18768
|
+
return result;
|
|
18769
|
+
}, []);
|
|
18770
|
+
if (styleNodes.length > 0) {
|
|
18771
|
+
definitionMap.set('styles', literalArr(styleNodes));
|
|
18772
|
+
}
|
|
18700
18773
|
}
|
|
18701
18774
|
else if (meta.encapsulation === exports.ViewEncapsulation.Emulated) {
|
|
18702
18775
|
// If there is no style, don't generate css selectors on elements
|
|
@@ -18723,8 +18796,9 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
18723
18796
|
* to be consumed by upstream compilations.
|
|
18724
18797
|
*/
|
|
18725
18798
|
function createComponentType(meta) {
|
|
18726
|
-
const typeParams =
|
|
18799
|
+
const typeParams = createBaseDirectiveTypeParams(meta);
|
|
18727
18800
|
typeParams.push(stringArrayAsType(meta.template.ngContentSelectors));
|
|
18801
|
+
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
18728
18802
|
return expressionType(importExpr(Identifiers.ComponentDeclaration, typeParams));
|
|
18729
18803
|
}
|
|
18730
18804
|
/**
|
|
@@ -18733,13 +18807,13 @@ function createComponentType(meta) {
|
|
|
18733
18807
|
*/
|
|
18734
18808
|
function compileDeclarationList(list, mode) {
|
|
18735
18809
|
switch (mode) {
|
|
18736
|
-
case 0 /* Direct */:
|
|
18810
|
+
case 0 /* DeclarationListEmitMode.Direct */:
|
|
18737
18811
|
// directives: [MyDir],
|
|
18738
18812
|
return list;
|
|
18739
|
-
case 1 /* Closure */:
|
|
18813
|
+
case 1 /* DeclarationListEmitMode.Closure */:
|
|
18740
18814
|
// directives: function () { return [MyDir]; }
|
|
18741
18815
|
return fn([], [new ReturnStatement(list)]);
|
|
18742
|
-
case 2 /* ClosureResolved */:
|
|
18816
|
+
case 2 /* DeclarationListEmitMode.ClosureResolved */:
|
|
18743
18817
|
// directives: function () { return [MyDir].map(ng.resolveForwardRef); }
|
|
18744
18818
|
const resolvedList = list.prop('map').callFn([importExpr(Identifiers.resolveForwardRef)]);
|
|
18745
18819
|
return fn([], [new ReturnStatement(resolvedList)]);
|
|
@@ -18757,9 +18831,9 @@ function prepareQueryParams(query, constantPool) {
|
|
|
18757
18831
|
* @param query
|
|
18758
18832
|
*/
|
|
18759
18833
|
function toQueryFlags(query) {
|
|
18760
|
-
return (query.descendants ? 1 /* descendants */ : 0 /* none */) |
|
|
18761
|
-
(query.static ? 2 /* isStatic */ : 0 /* none */) |
|
|
18762
|
-
(query.emitDistinctChangesOnly ? 4 /* emitDistinctChangesOnly */ : 0 /* none */);
|
|
18834
|
+
return (query.descendants ? 1 /* QueryFlags.descendants */ : 0 /* QueryFlags.none */) |
|
|
18835
|
+
(query.static ? 2 /* QueryFlags.isStatic */ : 0 /* QueryFlags.none */) |
|
|
18836
|
+
(query.emitDistinctChangesOnly ? 4 /* QueryFlags.emitDistinctChangesOnly */ : 0 /* QueryFlags.none */);
|
|
18763
18837
|
}
|
|
18764
18838
|
function convertAttributesToExpressions(attributes) {
|
|
18765
18839
|
const values = [];
|
|
@@ -18793,8 +18867,8 @@ function createContentQueriesFunction(queries, constantPool, name) {
|
|
|
18793
18867
|
new FnParam(RENDER_FLAGS, NUMBER_TYPE), new FnParam(CONTEXT_NAME, null),
|
|
18794
18868
|
new FnParam('dirIndex', null)
|
|
18795
18869
|
], [
|
|
18796
|
-
renderFlagCheckIfStmt(1 /* Create */, createStatements),
|
|
18797
|
-
renderFlagCheckIfStmt(2 /* Update */, updateStatements)
|
|
18870
|
+
renderFlagCheckIfStmt(1 /* core.RenderFlags.Create */, createStatements),
|
|
18871
|
+
renderFlagCheckIfStmt(2 /* core.RenderFlags.Update */, updateStatements)
|
|
18798
18872
|
], INFERRED_TYPE, null, contentQueriesFnName);
|
|
18799
18873
|
}
|
|
18800
18874
|
function stringAsType(str) {
|
|
@@ -18815,7 +18889,7 @@ function stringArrayAsType(arr) {
|
|
|
18815
18889
|
return arr.length > 0 ? expressionType(literalArr(arr.map(value => literal(value)))) :
|
|
18816
18890
|
NONE_TYPE;
|
|
18817
18891
|
}
|
|
18818
|
-
function
|
|
18892
|
+
function createBaseDirectiveTypeParams(meta) {
|
|
18819
18893
|
// On the type side, remove newlines from the selector as it will need to fit into a TypeScript
|
|
18820
18894
|
// string literal, which must be on one line.
|
|
18821
18895
|
const selectorForType = meta.selector !== null ? meta.selector.replace(/\n/g, '') : null;
|
|
@@ -18833,7 +18907,11 @@ function createDirectiveTypeParams(meta) {
|
|
|
18833
18907
|
* to be consumed by upstream compilations.
|
|
18834
18908
|
*/
|
|
18835
18909
|
function createDirectiveType(meta) {
|
|
18836
|
-
const typeParams =
|
|
18910
|
+
const typeParams = createBaseDirectiveTypeParams(meta);
|
|
18911
|
+
// Directives have no NgContentSelectors slot, but instead express a `never` type
|
|
18912
|
+
// so that future fields align.
|
|
18913
|
+
typeParams.push(NONE_TYPE);
|
|
18914
|
+
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
18837
18915
|
return expressionType(importExpr(Identifiers.DirectiveDeclaration, typeParams));
|
|
18838
18916
|
}
|
|
18839
18917
|
// Define and update any view queries
|
|
@@ -18856,8 +18934,8 @@ function createViewQueriesFunction(viewQueries, constantPool, name) {
|
|
|
18856
18934
|
});
|
|
18857
18935
|
const viewQueryFnName = name ? `${name}_Query` : null;
|
|
18858
18936
|
return fn([new FnParam(RENDER_FLAGS, NUMBER_TYPE), new FnParam(CONTEXT_NAME, null)], [
|
|
18859
|
-
renderFlagCheckIfStmt(1 /* Create */, createStatements),
|
|
18860
|
-
renderFlagCheckIfStmt(2 /* Update */, updateStatements)
|
|
18937
|
+
renderFlagCheckIfStmt(1 /* core.RenderFlags.Create */, createStatements),
|
|
18938
|
+
renderFlagCheckIfStmt(2 /* core.RenderFlags.Update */, updateStatements)
|
|
18861
18939
|
], INFERRED_TYPE, null, viewQueryFnName);
|
|
18862
18940
|
}
|
|
18863
18941
|
// Return a host binding function or null if one is not necessary.
|
|
@@ -18997,10 +19075,10 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
18997
19075
|
const hostBindingsFnName = name ? `${name}_HostBindings` : null;
|
|
18998
19076
|
const statements = [];
|
|
18999
19077
|
if (createInstructions.length > 0) {
|
|
19000
|
-
statements.push(renderFlagCheckIfStmt(1 /* Create */, getInstructionStatements(createInstructions)));
|
|
19078
|
+
statements.push(renderFlagCheckIfStmt(1 /* core.RenderFlags.Create */, getInstructionStatements(createInstructions)));
|
|
19001
19079
|
}
|
|
19002
19080
|
if (updateInstructions.length > 0) {
|
|
19003
|
-
statements.push(renderFlagCheckIfStmt(2 /* Update */, updateVariables.concat(getInstructionStatements(updateInstructions))));
|
|
19081
|
+
statements.push(renderFlagCheckIfStmt(2 /* core.RenderFlags.Update */, updateVariables.concat(getInstructionStatements(updateInstructions))));
|
|
19004
19082
|
}
|
|
19005
19083
|
return fn([new FnParam(RENDER_FLAGS, NUMBER_TYPE), new FnParam(CONTEXT_NAME, null)], statements, INFERRED_TYPE, null, hostBindingsFnName);
|
|
19006
19084
|
}
|
|
@@ -19041,12 +19119,12 @@ function createHostListeners(eventBindings, name) {
|
|
|
19041
19119
|
const instructions = [];
|
|
19042
19120
|
for (const binding of eventBindings) {
|
|
19043
19121
|
let bindingName = binding.name && sanitizeIdentifier(binding.name);
|
|
19044
|
-
const bindingFnName = binding.type === 1 /* Animation */ ?
|
|
19122
|
+
const bindingFnName = binding.type === 1 /* ParsedEventType.Animation */ ?
|
|
19045
19123
|
prepareSyntheticListenerFunctionName(bindingName, binding.targetOrPhase) :
|
|
19046
19124
|
bindingName;
|
|
19047
19125
|
const handlerName = name && bindingName ? `${name}_${bindingFnName}_HostBindingHandler` : null;
|
|
19048
19126
|
const params = prepareEventListenerParameters(BoundEvent.fromParsedEvent(binding), handlerName);
|
|
19049
|
-
if (binding.type == 1 /* Animation */) {
|
|
19127
|
+
if (binding.type == 1 /* ParsedEventType.Animation */) {
|
|
19050
19128
|
syntheticListenerParams.push(params);
|
|
19051
19129
|
}
|
|
19052
19130
|
else {
|
|
@@ -19095,7 +19173,7 @@ function parseHostBindings(host) {
|
|
|
19095
19173
|
}
|
|
19096
19174
|
}
|
|
19097
19175
|
}
|
|
19098
|
-
else if (matches[1 /* Binding */] != null) {
|
|
19176
|
+
else if (matches[1 /* HostBindingGroup.Binding */] != null) {
|
|
19099
19177
|
if (typeof value !== 'string') {
|
|
19100
19178
|
// TODO(alxhub): make this a diagnostic.
|
|
19101
19179
|
throw new Error(`Property binding must be string`);
|
|
@@ -19103,14 +19181,14 @@ function parseHostBindings(host) {
|
|
|
19103
19181
|
// synthetic properties (the ones that have a `@` as a prefix)
|
|
19104
19182
|
// are still treated the same as regular properties. Therefore
|
|
19105
19183
|
// there is no point in storing them in a separate map.
|
|
19106
|
-
properties[matches[1 /* Binding */]] = value;
|
|
19184
|
+
properties[matches[1 /* HostBindingGroup.Binding */]] = value;
|
|
19107
19185
|
}
|
|
19108
|
-
else if (matches[2 /* Event */] != null) {
|
|
19186
|
+
else if (matches[2 /* HostBindingGroup.Event */] != null) {
|
|
19109
19187
|
if (typeof value !== 'string') {
|
|
19110
19188
|
// TODO(alxhub): make this a diagnostic.
|
|
19111
19189
|
throw new Error(`Event binding must be string`);
|
|
19112
19190
|
}
|
|
19113
|
-
listeners[matches[2 /* Event */]] = value;
|
|
19191
|
+
listeners[matches[2 /* HostBindingGroup.Event */]] = value;
|
|
19114
19192
|
}
|
|
19115
19193
|
}
|
|
19116
19194
|
return { attributes, listeners, properties, specialAttributes };
|
|
@@ -19178,6 +19256,7 @@ class CompilerFacadeImpl {
|
|
|
19178
19256
|
deps: null,
|
|
19179
19257
|
pipeName: facade.pipeName,
|
|
19180
19258
|
pure: facade.pure,
|
|
19259
|
+
isStandalone: facade.isStandalone,
|
|
19181
19260
|
};
|
|
19182
19261
|
const res = compilePipeFromMetadata(metadata);
|
|
19183
19262
|
return this.jitExpression(res.expression, angularCoreEnv, sourceMapUrl, []);
|
|
@@ -19195,10 +19274,10 @@ class CompilerFacadeImpl {
|
|
|
19195
19274
|
internalType: new WrappedNodeExpr(facade.type),
|
|
19196
19275
|
typeArgumentCount: facade.typeArgumentCount,
|
|
19197
19276
|
providedIn: computeProvidedIn(facade.providedIn),
|
|
19198
|
-
useClass: convertToProviderExpression(facade,
|
|
19199
|
-
useFactory: wrapExpression(facade,
|
|
19200
|
-
useValue: convertToProviderExpression(facade,
|
|
19201
|
-
useExisting: convertToProviderExpression(facade,
|
|
19277
|
+
useClass: convertToProviderExpression(facade, 'useClass'),
|
|
19278
|
+
useFactory: wrapExpression(facade, 'useFactory'),
|
|
19279
|
+
useValue: convertToProviderExpression(facade, 'useValue'),
|
|
19280
|
+
useExisting: convertToProviderExpression(facade, 'useExisting'),
|
|
19202
19281
|
deps: (_a = facade.deps) === null || _a === void 0 ? void 0 : _a.map(convertR3DependencyMetadata),
|
|
19203
19282
|
},
|
|
19204
19283
|
/* resolveForwardRefs */ true);
|
|
@@ -19212,10 +19291,10 @@ class CompilerFacadeImpl {
|
|
|
19212
19291
|
internalType: new WrappedNodeExpr(facade.type),
|
|
19213
19292
|
typeArgumentCount: 0,
|
|
19214
19293
|
providedIn: computeProvidedIn(facade.providedIn),
|
|
19215
|
-
useClass: convertToProviderExpression(facade,
|
|
19216
|
-
useFactory: wrapExpression(facade,
|
|
19217
|
-
useValue: convertToProviderExpression(facade,
|
|
19218
|
-
useExisting: convertToProviderExpression(facade,
|
|
19294
|
+
useClass: convertToProviderExpression(facade, 'useClass'),
|
|
19295
|
+
useFactory: wrapExpression(facade, 'useFactory'),
|
|
19296
|
+
useValue: convertToProviderExpression(facade, 'useValue'),
|
|
19297
|
+
useExisting: convertToProviderExpression(facade, 'useExisting'),
|
|
19219
19298
|
deps: (_a = facade.deps) === null || _a === void 0 ? void 0 : _a.map(convertR3DeclareDependencyMetadata),
|
|
19220
19299
|
},
|
|
19221
19300
|
/* resolveForwardRefs */ true);
|
|
@@ -19246,7 +19325,7 @@ class CompilerFacadeImpl {
|
|
|
19246
19325
|
declarations: facade.declarations.map(wrapReference),
|
|
19247
19326
|
imports: facade.imports.map(wrapReference),
|
|
19248
19327
|
exports: facade.exports.map(wrapReference),
|
|
19249
|
-
|
|
19328
|
+
selectorScopeMode: exports.R3SelectorScopeMode.Inline,
|
|
19250
19329
|
containsForwardDecls: false,
|
|
19251
19330
|
schemas: facade.schemas ? facade.schemas.map(wrapReference) : null,
|
|
19252
19331
|
id: facade.id ? new WrappedNodeExpr(facade.id) : null,
|
|
@@ -19277,7 +19356,7 @@ class CompilerFacadeImpl {
|
|
|
19277
19356
|
// Parse the template and check for errors.
|
|
19278
19357
|
const { template, interpolation } = parseJitTemplate(facade.template, facade.name, sourceMapUrl, facade.preserveWhitespaces, facade.interpolation);
|
|
19279
19358
|
// Compile the component metadata, including template, into an expression.
|
|
19280
|
-
const meta = Object.assign(Object.assign(Object.assign({}, facade), convertDirectiveFacadeToMetadata(facade)), { selector: facade.selector || this.elementSchemaRegistry.getDefaultComponentElementName(), template, declarationListEmitMode: 0 /* Direct */, styles: [...facade.styles, ...template.styles], encapsulation: facade.encapsulation, interpolation, changeDetection: facade.changeDetection, animations: facade.animations != null ? new WrappedNodeExpr(facade.animations) : null, viewProviders: facade.viewProviders != null ? new WrappedNodeExpr(facade.viewProviders) :
|
|
19359
|
+
const meta = Object.assign(Object.assign(Object.assign({}, facade), convertDirectiveFacadeToMetadata(facade)), { selector: facade.selector || this.elementSchemaRegistry.getDefaultComponentElementName(), template, declarations: facade.declarations.map(convertDeclarationFacadeToMetadata), declarationListEmitMode: 0 /* DeclarationListEmitMode.Direct */, styles: [...facade.styles, ...template.styles], encapsulation: facade.encapsulation, interpolation, changeDetection: facade.changeDetection, animations: facade.animations != null ? new WrappedNodeExpr(facade.animations) : null, viewProviders: facade.viewProviders != null ? new WrappedNodeExpr(facade.viewProviders) :
|
|
19281
19360
|
null, relativeContextFilePath: '', i18nUseExternalIds: true });
|
|
19282
19361
|
const jitExpressionSourceMap = `ng:///${facade.name}.js`;
|
|
19283
19362
|
return this.compileComponentFromMeta(angularCoreEnv, jitExpressionSourceMap, meta);
|
|
@@ -19340,10 +19419,6 @@ class CompilerFacadeImpl {
|
|
|
19340
19419
|
return res['$def'];
|
|
19341
19420
|
}
|
|
19342
19421
|
}
|
|
19343
|
-
const USE_CLASS = Object.keys({ useClass: null })[0];
|
|
19344
|
-
const USE_FACTORY = Object.keys({ useFactory: null })[0];
|
|
19345
|
-
const USE_VALUE = Object.keys({ useValue: null })[0];
|
|
19346
|
-
const USE_EXISTING = Object.keys({ useExisting: null })[0];
|
|
19347
19422
|
function convertToR3QueryMetadata(facade) {
|
|
19348
19423
|
return Object.assign(Object.assign({}, facade), { predicate: convertQueryPredicate(facade.predicate), read: facade.read ? new WrappedNodeExpr(facade.read) : null, static: facade.static, emitDistinctChangesOnly: facade.emitDistinctChangesOnly });
|
|
19349
19424
|
}
|
|
@@ -19364,7 +19439,7 @@ function convertQueryPredicate(predicate) {
|
|
|
19364
19439
|
// The predicate is an array of strings so pass it through.
|
|
19365
19440
|
predicate :
|
|
19366
19441
|
// The predicate is a type - assume that we will need to unwrap any `forwardRef()` calls.
|
|
19367
|
-
createMayBeForwardRefExpression(new WrappedNodeExpr(predicate), 1 /* Wrapped */);
|
|
19442
|
+
createMayBeForwardRefExpression(new WrappedNodeExpr(predicate), 1 /* ForwardRefHandling.Wrapped */);
|
|
19368
19443
|
}
|
|
19369
19444
|
function convertDirectiveFacadeToMetadata(facade) {
|
|
19370
19445
|
const inputsFromMetadata = parseInputOutputs(facade.inputs || []);
|
|
@@ -19388,7 +19463,7 @@ function convertDirectiveFacadeToMetadata(facade) {
|
|
|
19388
19463
|
return Object.assign(Object.assign({}, facade), { typeArgumentCount: 0, typeSourceSpan: facade.typeSourceSpan, type: wrapReference(facade.type), internalType: new WrappedNodeExpr(facade.type), deps: null, host: extractHostBindings(facade.propMetadata, facade.typeSourceSpan, facade.host), inputs: Object.assign(Object.assign({}, inputsFromMetadata), inputsFromType), outputs: Object.assign(Object.assign({}, outputsFromMetadata), outputsFromType), queries: facade.queries.map(convertToR3QueryMetadata), providers: facade.providers != null ? new WrappedNodeExpr(facade.providers) : null, viewQueries: facade.viewQueries.map(convertToR3QueryMetadata), fullInheritance: false });
|
|
19389
19464
|
}
|
|
19390
19465
|
function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
19391
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19466
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
19392
19467
|
return {
|
|
19393
19468
|
name: declaration.type.name,
|
|
19394
19469
|
type: wrapReference(declaration.type),
|
|
@@ -19408,6 +19483,7 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
|
19408
19483
|
deps: null,
|
|
19409
19484
|
typeArgumentCount: 0,
|
|
19410
19485
|
fullInheritance: false,
|
|
19486
|
+
isStandalone: (_j = declaration.isStandalone) !== null && _j !== void 0 ? _j : false,
|
|
19411
19487
|
};
|
|
19412
19488
|
}
|
|
19413
19489
|
function convertHostDeclarationToMetadata(host = {}) {
|
|
@@ -19429,19 +19505,43 @@ function convertOpaqueValuesToExpressions(obj) {
|
|
|
19429
19505
|
}
|
|
19430
19506
|
return result;
|
|
19431
19507
|
}
|
|
19432
|
-
function convertDeclareComponentFacadeToMetadata(
|
|
19433
|
-
var _a, _b, _c, _d
|
|
19434
|
-
const { template, interpolation } = parseJitTemplate(
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19441
|
-
|
|
19442
|
-
|
|
19508
|
+
function convertDeclareComponentFacadeToMetadata(decl, typeSourceSpan, sourceMapUrl) {
|
|
19509
|
+
var _a, _b, _c, _d;
|
|
19510
|
+
const { template, interpolation } = parseJitTemplate(decl.template, decl.type.name, sourceMapUrl, (_a = decl.preserveWhitespaces) !== null && _a !== void 0 ? _a : false, decl.interpolation);
|
|
19511
|
+
const declarations = [];
|
|
19512
|
+
if (decl.dependencies) {
|
|
19513
|
+
for (const innerDep of decl.dependencies) {
|
|
19514
|
+
switch (innerDep.kind) {
|
|
19515
|
+
case 'directive':
|
|
19516
|
+
case 'component':
|
|
19517
|
+
declarations.push(convertDirectiveDeclarationToMetadata(innerDep));
|
|
19518
|
+
break;
|
|
19519
|
+
case 'pipe':
|
|
19520
|
+
declarations.push(convertPipeDeclarationToMetadata(innerDep));
|
|
19521
|
+
break;
|
|
19522
|
+
}
|
|
19523
|
+
}
|
|
19524
|
+
}
|
|
19525
|
+
else if (decl.components || decl.directives || decl.pipes) {
|
|
19526
|
+
// Existing declarations on NPM may not be using the new `dependencies` merged field, and may
|
|
19527
|
+
// have separate fields for dependencies instead. Unify them for JIT compilation.
|
|
19528
|
+
decl.components &&
|
|
19529
|
+
declarations.push(...decl.components.map(dir => convertDirectiveDeclarationToMetadata(dir, /* isComponent */ true)));
|
|
19530
|
+
decl.directives &&
|
|
19531
|
+
declarations.push(...decl.directives.map(dir => convertDirectiveDeclarationToMetadata(dir)));
|
|
19532
|
+
decl.pipes && declarations.push(...convertPipeMapToMetadata(decl.pipes));
|
|
19533
|
+
}
|
|
19534
|
+
return Object.assign(Object.assign({}, convertDeclareDirectiveFacadeToMetadata(decl, typeSourceSpan)), { template, styles: (_b = decl.styles) !== null && _b !== void 0 ? _b : [], declarations, viewProviders: decl.viewProviders !== undefined ? new WrappedNodeExpr(decl.viewProviders) :
|
|
19535
|
+
null, animations: decl.animations !== undefined ? new WrappedNodeExpr(decl.animations) : null, changeDetection: (_c = decl.changeDetection) !== null && _c !== void 0 ? _c : exports.ChangeDetectionStrategy.Default, encapsulation: (_d = decl.encapsulation) !== null && _d !== void 0 ? _d : exports.ViewEncapsulation.Emulated, interpolation, declarationListEmitMode: 2 /* DeclarationListEmitMode.ClosureResolved */, relativeContextFilePath: '', i18nUseExternalIds: true });
|
|
19536
|
+
}
|
|
19537
|
+
function convertDeclarationFacadeToMetadata(declaration) {
|
|
19538
|
+
return Object.assign(Object.assign({}, declaration), { type: new WrappedNodeExpr(declaration.type) });
|
|
19539
|
+
}
|
|
19540
|
+
function convertDirectiveDeclarationToMetadata(declaration, isComponent = null) {
|
|
19443
19541
|
var _a, _b, _c;
|
|
19444
19542
|
return {
|
|
19543
|
+
kind: exports.R3TemplateDependencyKind.Directive,
|
|
19544
|
+
isComponent: isComponent || declaration.kind === 'component',
|
|
19445
19545
|
selector: declaration.selector,
|
|
19446
19546
|
type: new WrappedNodeExpr(declaration.type),
|
|
19447
19547
|
inputs: (_a = declaration.inputs) !== null && _a !== void 0 ? _a : [],
|
|
@@ -19449,16 +19549,24 @@ function convertUsedDirectiveDeclarationToMetadata(declaration) {
|
|
|
19449
19549
|
exportAs: (_c = declaration.exportAs) !== null && _c !== void 0 ? _c : null,
|
|
19450
19550
|
};
|
|
19451
19551
|
}
|
|
19452
|
-
function
|
|
19453
|
-
|
|
19454
|
-
|
|
19455
|
-
return pipes;
|
|
19456
|
-
}
|
|
19457
|
-
for (const pipeName of Object.keys(declaredPipes)) {
|
|
19458
|
-
const pipeType = declaredPipes[pipeName];
|
|
19459
|
-
pipes.set(pipeName, new WrappedNodeExpr(pipeType));
|
|
19552
|
+
function convertPipeMapToMetadata(pipes) {
|
|
19553
|
+
if (!pipes) {
|
|
19554
|
+
return [];
|
|
19460
19555
|
}
|
|
19461
|
-
return pipes
|
|
19556
|
+
return Object.keys(pipes).map(name => {
|
|
19557
|
+
return {
|
|
19558
|
+
kind: exports.R3TemplateDependencyKind.Pipe,
|
|
19559
|
+
name,
|
|
19560
|
+
type: new WrappedNodeExpr(pipes[name]),
|
|
19561
|
+
};
|
|
19562
|
+
});
|
|
19563
|
+
}
|
|
19564
|
+
function convertPipeDeclarationToMetadata(pipe) {
|
|
19565
|
+
return {
|
|
19566
|
+
kind: exports.R3TemplateDependencyKind.Pipe,
|
|
19567
|
+
name: pipe.name,
|
|
19568
|
+
type: new WrappedNodeExpr(pipe.type),
|
|
19569
|
+
};
|
|
19462
19570
|
}
|
|
19463
19571
|
function parseJitTemplate(template, typeName, sourceMapUrl, preserveWhitespaces, interpolation) {
|
|
19464
19572
|
const interpolationConfig = interpolation ? InterpolationConfig.fromArray(interpolation) : DEFAULT_INTERPOLATION_CONFIG;
|
|
@@ -19480,7 +19588,7 @@ function parseJitTemplate(template, typeName, sourceMapUrl, preserveWhitespaces,
|
|
|
19480
19588
|
*/
|
|
19481
19589
|
function convertToProviderExpression(obj, property) {
|
|
19482
19590
|
if (obj.hasOwnProperty(property)) {
|
|
19483
|
-
return createMayBeForwardRefExpression(new WrappedNodeExpr(obj[property]), 0 /* None */);
|
|
19591
|
+
return createMayBeForwardRefExpression(new WrappedNodeExpr(obj[property]), 0 /* ForwardRefHandling.None */);
|
|
19484
19592
|
}
|
|
19485
19593
|
else {
|
|
19486
19594
|
return undefined;
|
|
@@ -19498,7 +19606,7 @@ function computeProvidedIn(providedIn) {
|
|
|
19498
19606
|
const expression = typeof providedIn === 'function' ? new WrappedNodeExpr(providedIn) :
|
|
19499
19607
|
new LiteralExpr(providedIn !== null && providedIn !== void 0 ? providedIn : null);
|
|
19500
19608
|
// See `convertToProviderExpression()` for why this uses `ForwardRefHandling.None`.
|
|
19501
|
-
return createMayBeForwardRefExpression(expression, 0 /* None */);
|
|
19609
|
+
return createMayBeForwardRefExpression(expression, 0 /* ForwardRefHandling.None */);
|
|
19502
19610
|
}
|
|
19503
19611
|
function convertR3DependencyMetadataArray(facades) {
|
|
19504
19612
|
return facades == null ? null : facades.map(convertR3DependencyMetadata);
|
|
@@ -19571,7 +19679,7 @@ function parseInputOutputs(values) {
|
|
|
19571
19679
|
}, {});
|
|
19572
19680
|
}
|
|
19573
19681
|
function convertDeclarePipeFacadeToMetadata(declaration) {
|
|
19574
|
-
var _a;
|
|
19682
|
+
var _a, _b;
|
|
19575
19683
|
return {
|
|
19576
19684
|
name: declaration.type.name,
|
|
19577
19685
|
type: wrapReference(declaration.type),
|
|
@@ -19580,6 +19688,7 @@ function convertDeclarePipeFacadeToMetadata(declaration) {
|
|
|
19580
19688
|
pipeName: declaration.name,
|
|
19581
19689
|
deps: null,
|
|
19582
19690
|
pure: (_a = declaration.pure) !== null && _a !== void 0 ? _a : true,
|
|
19691
|
+
isStandalone: (_b = declaration.isStandalone) !== null && _b !== void 0 ? _b : false,
|
|
19583
19692
|
};
|
|
19584
19693
|
}
|
|
19585
19694
|
function convertDeclareInjectorFacadeToMetadata(declaration) {
|
|
@@ -19606,7 +19715,7 @@ function publishFacade(global) {
|
|
|
19606
19715
|
* Use of this source code is governed by an MIT-style license that can be
|
|
19607
19716
|
* found in the LICENSE file at https://angular.io/license
|
|
19608
19717
|
*/
|
|
19609
|
-
const VERSION = new Version('
|
|
19718
|
+
const VERSION = new Version('14.0.0');
|
|
19610
19719
|
|
|
19611
19720
|
/**
|
|
19612
19721
|
* @license
|
|
@@ -21633,7 +21742,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
|
|
|
21633
21742
|
function compileDeclareClassMetadata(metadata) {
|
|
21634
21743
|
const definitionMap = new DefinitionMap();
|
|
21635
21744
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
21636
|
-
definitionMap.set('version', literal('
|
|
21745
|
+
definitionMap.set('version', literal('14.0.0'));
|
|
21637
21746
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21638
21747
|
definitionMap.set('type', metadata.type);
|
|
21639
21748
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -21733,7 +21842,7 @@ function compileDependency(dep) {
|
|
|
21733
21842
|
*
|
|
21734
21843
|
* Do not include any prerelease in these versions as they are ignored.
|
|
21735
21844
|
*/
|
|
21736
|
-
const MINIMUM_PARTIAL_LINKER_VERSION$5 = '
|
|
21845
|
+
const MINIMUM_PARTIAL_LINKER_VERSION$5 = '14.0.0';
|
|
21737
21846
|
/**
|
|
21738
21847
|
* Compile a directive declaration defined by the `R3DirectiveMetadata`.
|
|
21739
21848
|
*/
|
|
@@ -21750,9 +21859,12 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
21750
21859
|
function createDirectiveDefinitionMap(meta) {
|
|
21751
21860
|
const definitionMap = new DefinitionMap();
|
|
21752
21861
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
21753
|
-
definitionMap.set('version', literal('
|
|
21862
|
+
definitionMap.set('version', literal('14.0.0'));
|
|
21754
21863
|
// e.g. `type: MyDirective`
|
|
21755
21864
|
definitionMap.set('type', meta.internalType);
|
|
21865
|
+
if (meta.isStandalone) {
|
|
21866
|
+
definitionMap.set('isStandalone', literal(meta.isStandalone));
|
|
21867
|
+
}
|
|
21756
21868
|
// e.g. `selector: 'some-dir'`
|
|
21757
21869
|
if (meta.selector !== null) {
|
|
21758
21870
|
definitionMap.set('selector', literal(meta.selector));
|
|
@@ -21854,9 +21966,7 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
21854
21966
|
definitionMap.set('isInline', literal(true));
|
|
21855
21967
|
}
|
|
21856
21968
|
definitionMap.set('styles', toOptionalLiteralArray(meta.styles, literal));
|
|
21857
|
-
definitionMap.set('
|
|
21858
|
-
definitionMap.set('directives', compileUsedDirectiveMetadata(meta, directive => directive.isComponent !== true));
|
|
21859
|
-
definitionMap.set('pipes', compileUsedPipeMetadata(meta));
|
|
21969
|
+
definitionMap.set('dependencies', compileUsedDependenciesMetadata(meta));
|
|
21860
21970
|
definitionMap.set('viewProviders', meta.viewProviders);
|
|
21861
21971
|
definitionMap.set('animations', meta.animations);
|
|
21862
21972
|
if (meta.changeDetection !== undefined) {
|
|
@@ -21912,43 +22022,35 @@ function computeEndLocation(file, contents) {
|
|
|
21912
22022
|
} while (lineStart !== -1);
|
|
21913
22023
|
return new ParseLocation(file, length, line, length - lastLineStart);
|
|
21914
22024
|
}
|
|
21915
|
-
|
|
21916
|
-
|
|
21917
|
-
* individual directives. If the component does not use any directives, then null is returned.
|
|
21918
|
-
*/
|
|
21919
|
-
function compileUsedDirectiveMetadata(meta, predicate) {
|
|
21920
|
-
const wrapType = meta.declarationListEmitMode !== 0 /* Direct */ ?
|
|
22025
|
+
function compileUsedDependenciesMetadata(meta) {
|
|
22026
|
+
const wrapType = meta.declarationListEmitMode !== 0 /* DeclarationListEmitMode.Direct */ ?
|
|
21921
22027
|
generateForwardRef :
|
|
21922
22028
|
(expr) => expr;
|
|
21923
|
-
|
|
21924
|
-
|
|
21925
|
-
|
|
21926
|
-
|
|
21927
|
-
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
|
|
22029
|
+
return toOptionalLiteralArray(meta.declarations, decl => {
|
|
22030
|
+
switch (decl.kind) {
|
|
22031
|
+
case exports.R3TemplateDependencyKind.Directive:
|
|
22032
|
+
const dirMeta = new DefinitionMap();
|
|
22033
|
+
dirMeta.set('kind', literal(decl.isComponent ? 'component' : 'directive'));
|
|
22034
|
+
dirMeta.set('type', wrapType(decl.type));
|
|
22035
|
+
dirMeta.set('selector', literal(decl.selector));
|
|
22036
|
+
dirMeta.set('inputs', toOptionalLiteralArray(decl.inputs, literal));
|
|
22037
|
+
dirMeta.set('outputs', toOptionalLiteralArray(decl.outputs, literal));
|
|
22038
|
+
dirMeta.set('exportAs', toOptionalLiteralArray(decl.exportAs, literal));
|
|
22039
|
+
return dirMeta.toLiteralMap();
|
|
22040
|
+
case exports.R3TemplateDependencyKind.Pipe:
|
|
22041
|
+
const pipeMeta = new DefinitionMap();
|
|
22042
|
+
pipeMeta.set('kind', literal('pipe'));
|
|
22043
|
+
pipeMeta.set('type', wrapType(decl.type));
|
|
22044
|
+
pipeMeta.set('name', literal(decl.name));
|
|
22045
|
+
return pipeMeta.toLiteralMap();
|
|
22046
|
+
case exports.R3TemplateDependencyKind.NgModule:
|
|
22047
|
+
const ngModuleMeta = new DefinitionMap();
|
|
22048
|
+
ngModuleMeta.set('kind', literal('ngmodule'));
|
|
22049
|
+
ngModuleMeta.set('type', wrapType(decl.type));
|
|
22050
|
+
return ngModuleMeta.toLiteralMap();
|
|
22051
|
+
}
|
|
21932
22052
|
});
|
|
21933
22053
|
}
|
|
21934
|
-
/**
|
|
21935
|
-
* Compiles the pipes as registered in the component metadata into an object literal, where the
|
|
21936
|
-
* pipe's name is used as key and a reference to its type as value. If the component does not use
|
|
21937
|
-
* any pipes, then null is returned.
|
|
21938
|
-
*/
|
|
21939
|
-
function compileUsedPipeMetadata(meta) {
|
|
21940
|
-
if (meta.pipes.size === 0) {
|
|
21941
|
-
return null;
|
|
21942
|
-
}
|
|
21943
|
-
const wrapType = meta.declarationListEmitMode !== 0 /* Direct */ ?
|
|
21944
|
-
generateForwardRef :
|
|
21945
|
-
(expr) => expr;
|
|
21946
|
-
const entries = [];
|
|
21947
|
-
for (const [name, pipe] of meta.pipes) {
|
|
21948
|
-
entries.push({ key: name, value: wrapType(pipe), quoted: true });
|
|
21949
|
-
}
|
|
21950
|
-
return literalMap(entries);
|
|
21951
|
-
}
|
|
21952
22054
|
|
|
21953
22055
|
/**
|
|
21954
22056
|
* @license
|
|
@@ -21968,7 +22070,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
21968
22070
|
function compileDeclareFactoryFunction(meta) {
|
|
21969
22071
|
const definitionMap = new DefinitionMap();
|
|
21970
22072
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
21971
|
-
definitionMap.set('version', literal('
|
|
22073
|
+
definitionMap.set('version', literal('14.0.0'));
|
|
21972
22074
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21973
22075
|
definitionMap.set('type', meta.internalType);
|
|
21974
22076
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -22010,7 +22112,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
22010
22112
|
function createInjectableDefinitionMap(meta) {
|
|
22011
22113
|
const definitionMap = new DefinitionMap();
|
|
22012
22114
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
22013
|
-
definitionMap.set('version', literal('
|
|
22115
|
+
definitionMap.set('version', literal('14.0.0'));
|
|
22014
22116
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22015
22117
|
definitionMap.set('type', meta.internalType);
|
|
22016
22118
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -22068,7 +22170,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
22068
22170
|
function createInjectorDefinitionMap(meta) {
|
|
22069
22171
|
const definitionMap = new DefinitionMap();
|
|
22070
22172
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
22071
|
-
definitionMap.set('version', literal('
|
|
22173
|
+
definitionMap.set('version', literal('14.0.0'));
|
|
22072
22174
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22073
22175
|
definitionMap.set('type', meta.internalType);
|
|
22074
22176
|
definitionMap.set('providers', meta.providers);
|
|
@@ -22092,7 +22194,7 @@ function createInjectorDefinitionMap(meta) {
|
|
|
22092
22194
|
*
|
|
22093
22195
|
* Do not include any prerelease in these versions as they are ignored.
|
|
22094
22196
|
*/
|
|
22095
|
-
const MINIMUM_PARTIAL_LINKER_VERSION$1 = '
|
|
22197
|
+
const MINIMUM_PARTIAL_LINKER_VERSION$1 = '14.0.0';
|
|
22096
22198
|
function compileDeclareNgModuleFromMetadata(meta) {
|
|
22097
22199
|
const definitionMap = createNgModuleDefinitionMap(meta);
|
|
22098
22200
|
const expression = importExpr(Identifiers.declareNgModule).callFn([definitionMap.toLiteralMap()]);
|
|
@@ -22105,7 +22207,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
|
|
|
22105
22207
|
function createNgModuleDefinitionMap(meta) {
|
|
22106
22208
|
const definitionMap = new DefinitionMap();
|
|
22107
22209
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
22108
|
-
definitionMap.set('version', literal('
|
|
22210
|
+
definitionMap.set('version', literal('14.0.0'));
|
|
22109
22211
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22110
22212
|
definitionMap.set('type', meta.internalType);
|
|
22111
22213
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -22147,7 +22249,7 @@ function createNgModuleDefinitionMap(meta) {
|
|
|
22147
22249
|
*
|
|
22148
22250
|
* Do not include any prerelease in these versions as they are ignored.
|
|
22149
22251
|
*/
|
|
22150
|
-
const MINIMUM_PARTIAL_LINKER_VERSION = '
|
|
22252
|
+
const MINIMUM_PARTIAL_LINKER_VERSION = '14.0.0';
|
|
22151
22253
|
/**
|
|
22152
22254
|
* Compile a Pipe declaration defined by the `R3PipeMetadata`.
|
|
22153
22255
|
*/
|
|
@@ -22163,10 +22265,13 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
22163
22265
|
function createPipeDefinitionMap(meta) {
|
|
22164
22266
|
const definitionMap = new DefinitionMap();
|
|
22165
22267
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
22166
|
-
definitionMap.set('version', literal('
|
|
22268
|
+
definitionMap.set('version', literal('14.0.0'));
|
|
22167
22269
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22168
22270
|
// e.g. `type: MyPipe`
|
|
22169
22271
|
definitionMap.set('type', meta.internalType);
|
|
22272
|
+
if (meta.isStandalone) {
|
|
22273
|
+
definitionMap.set('isStandalone', literal(meta.isStandalone));
|
|
22274
|
+
}
|
|
22170
22275
|
// e.g. `name: "myPipe"`
|
|
22171
22276
|
definitionMap.set('name', literal(meta.pipeName));
|
|
22172
22277
|
if (meta.pure === false) {
|
|
@@ -22273,7 +22378,6 @@ exports.ParserError = ParserError;
|
|
|
22273
22378
|
exports.PrefixNot = PrefixNot;
|
|
22274
22379
|
exports.PropertyRead = PropertyRead;
|
|
22275
22380
|
exports.PropertyWrite = PropertyWrite;
|
|
22276
|
-
exports.Quote = Quote;
|
|
22277
22381
|
exports.R3BoundTarget = R3BoundTarget;
|
|
22278
22382
|
exports.R3Identifiers = Identifiers;
|
|
22279
22383
|
exports.R3TargetBinder = R3TargetBinder;
|