@angular/compiler 14.2.0-next.1 → 15.0.0-next.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/esm2020/src/compiler_facade_interface.mjs +1 -1
- package/esm2020/src/expression_parser/parser.mjs +10 -2
- package/esm2020/src/jit_compiler_facade.mjs +23 -1
- package/esm2020/src/render3/partial/api.mjs +1 -1
- package/esm2020/src/render3/partial/class_metadata.mjs +1 -1
- package/esm2020/src/render3/partial/directive.mjs +29 -4
- package/esm2020/src/render3/partial/factory.mjs +1 -1
- package/esm2020/src/render3/partial/injectable.mjs +1 -1
- package/esm2020/src/render3/partial/injector.mjs +1 -1
- package/esm2020/src/render3/partial/ng_module.mjs +1 -1
- package/esm2020/src/render3/partial/pipe.mjs +1 -1
- package/esm2020/src/render3/r3_identifiers.mjs +2 -1
- package/esm2020/src/render3/view/api.mjs +1 -1
- package/esm2020/src/render3/view/compiler.mjs +72 -5
- package/esm2020/src/render3/view/t2_binder.mjs +2 -2
- package/esm2020/src/shadow_css.mjs +1 -1
- package/esm2020/src/version.mjs +1 -1
- package/fesm2015/compiler.mjs +142 -16
- package/fesm2015/compiler.mjs.map +1 -1
- package/fesm2015/testing.mjs +1 -1
- package/fesm2020/compiler.mjs +138 -15
- package/fesm2020/compiler.mjs.map +1 -1
- package/fesm2020/testing.mjs +1 -1
- package/index.d.ts +39 -2
- package/package.json +2 -2
- package/testing/index.d.ts +1 -1
package/fesm2015/testing.mjs
CHANGED
package/fesm2020/compiler.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular
|
|
2
|
+
* @license Angular v15.0.0-next.0
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -2922,6 +2922,7 @@ Identifiers.InheritDefinitionFeature = { name: 'ɵɵInheritDefinitionFeature', m
|
|
|
2922
2922
|
Identifiers.CopyDefinitionFeature = { name: 'ɵɵCopyDefinitionFeature', moduleName: CORE };
|
|
2923
2923
|
Identifiers.StandaloneFeature = { name: 'ɵɵStandaloneFeature', moduleName: CORE };
|
|
2924
2924
|
Identifiers.ProvidersFeature = { name: 'ɵɵProvidersFeature', moduleName: CORE };
|
|
2925
|
+
Identifiers.HostDirectivesFeature = { name: 'ɵɵHostDirectivesFeature', moduleName: CORE };
|
|
2925
2926
|
Identifiers.listener = { name: 'ɵɵlistener', moduleName: CORE };
|
|
2926
2927
|
Identifiers.getInheritedFactory = {
|
|
2927
2928
|
name: 'ɵɵgetInheritedFactory',
|
|
@@ -9955,10 +9956,18 @@ class _ParseAST {
|
|
|
9955
9956
|
} // read all semicolons
|
|
9956
9957
|
}
|
|
9957
9958
|
else if (this.index < this.tokens.length) {
|
|
9959
|
+
const errorIndex = this.index;
|
|
9958
9960
|
this.error(`Unexpected token '${this.next}'`);
|
|
9961
|
+
// The `error` call above will skip ahead to the next recovery point in an attempt to
|
|
9962
|
+
// recover part of the expression, but that might be the token we started from which will
|
|
9963
|
+
// lead to an infinite loop. If that's the case, break the loop assuming that we can't
|
|
9964
|
+
// parse further.
|
|
9965
|
+
if (this.index === errorIndex) {
|
|
9966
|
+
break;
|
|
9967
|
+
}
|
|
9959
9968
|
}
|
|
9960
9969
|
}
|
|
9961
|
-
if (exprs.length
|
|
9970
|
+
if (exprs.length === 0) {
|
|
9962
9971
|
// We have no expressions so create an empty expression that spans the entire input length
|
|
9963
9972
|
const artificialStart = this.offset;
|
|
9964
9973
|
const artificialEnd = this.offset + this.input.length;
|
|
@@ -18821,6 +18830,9 @@ function addFeatures(definitionMap, meta) {
|
|
|
18821
18830
|
if (meta.hasOwnProperty('template') && meta.isStandalone) {
|
|
18822
18831
|
features.push(importExpr(Identifiers.StandaloneFeature));
|
|
18823
18832
|
}
|
|
18833
|
+
if (meta.hostDirectives?.length) {
|
|
18834
|
+
features.push(importExpr(Identifiers.HostDirectivesFeature).callFn([createHostDirectivesFeatureArg(meta.hostDirectives)]));
|
|
18835
|
+
}
|
|
18824
18836
|
if (features.length) {
|
|
18825
18837
|
definitionMap.set('features', literalArr(features));
|
|
18826
18838
|
}
|
|
@@ -18933,6 +18945,7 @@ function createComponentType(meta) {
|
|
|
18933
18945
|
const typeParams = createBaseDirectiveTypeParams(meta);
|
|
18934
18946
|
typeParams.push(stringArrayAsType(meta.template.ngContentSelectors));
|
|
18935
18947
|
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
18948
|
+
typeParams.push(createHostDirectivesType(meta));
|
|
18936
18949
|
return expressionType(importExpr(Identifiers.ComponentDeclaration, typeParams));
|
|
18937
18950
|
}
|
|
18938
18951
|
/**
|
|
@@ -19008,7 +19021,7 @@ function createContentQueriesFunction(queries, constantPool, name) {
|
|
|
19008
19021
|
function stringAsType(str) {
|
|
19009
19022
|
return expressionType(literal(str));
|
|
19010
19023
|
}
|
|
19011
|
-
function
|
|
19024
|
+
function stringMapAsLiteralExpression(map) {
|
|
19012
19025
|
const mapValues = Object.keys(map).map(key => {
|
|
19013
19026
|
const value = Array.isArray(map[key]) ? map[key][0] : map[key];
|
|
19014
19027
|
return {
|
|
@@ -19017,7 +19030,7 @@ function stringMapAsType(map) {
|
|
|
19017
19030
|
quoted: true,
|
|
19018
19031
|
};
|
|
19019
19032
|
});
|
|
19020
|
-
return
|
|
19033
|
+
return literalMap(mapValues);
|
|
19021
19034
|
}
|
|
19022
19035
|
function stringArrayAsType(arr) {
|
|
19023
19036
|
return arr.length > 0 ? expressionType(literalArr(arr.map(value => literal(value)))) :
|
|
@@ -19031,8 +19044,8 @@ function createBaseDirectiveTypeParams(meta) {
|
|
|
19031
19044
|
typeWithParameters(meta.type.type, meta.typeArgumentCount),
|
|
19032
19045
|
selectorForType !== null ? stringAsType(selectorForType) : NONE_TYPE,
|
|
19033
19046
|
meta.exportAs !== null ? stringArrayAsType(meta.exportAs) : NONE_TYPE,
|
|
19034
|
-
|
|
19035
|
-
|
|
19047
|
+
expressionType(stringMapAsLiteralExpression(meta.inputs)),
|
|
19048
|
+
expressionType(stringMapAsLiteralExpression(meta.outputs)),
|
|
19036
19049
|
stringArrayAsType(meta.queries.map(q => q.propertyName)),
|
|
19037
19050
|
];
|
|
19038
19051
|
}
|
|
@@ -19046,6 +19059,7 @@ function createDirectiveType(meta) {
|
|
|
19046
19059
|
// so that future fields align.
|
|
19047
19060
|
typeParams.push(NONE_TYPE);
|
|
19048
19061
|
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
19062
|
+
typeParams.push(createHostDirectivesType(meta));
|
|
19049
19063
|
return expressionType(importExpr(Identifiers.DirectiveDeclaration, typeParams));
|
|
19050
19064
|
}
|
|
19051
19065
|
// Define and update any view queries
|
|
@@ -19349,6 +19363,68 @@ function compileStyles(styles, selector, hostSelector) {
|
|
|
19349
19363
|
return shadowCss.shimCssText(style, selector, hostSelector);
|
|
19350
19364
|
});
|
|
19351
19365
|
}
|
|
19366
|
+
function createHostDirectivesType(meta) {
|
|
19367
|
+
if (!meta.hostDirectives?.length) {
|
|
19368
|
+
return NONE_TYPE;
|
|
19369
|
+
}
|
|
19370
|
+
return expressionType(literalArr(meta.hostDirectives.map(hostMeta => literalMap([
|
|
19371
|
+
{ key: 'directive', value: typeofExpr(hostMeta.directive.type), quoted: false },
|
|
19372
|
+
{ key: 'inputs', value: stringMapAsLiteralExpression(hostMeta.inputs || {}), quoted: false },
|
|
19373
|
+
{ key: 'outputs', value: stringMapAsLiteralExpression(hostMeta.outputs || {}), quoted: false },
|
|
19374
|
+
]))));
|
|
19375
|
+
}
|
|
19376
|
+
function createHostDirectivesFeatureArg(hostDirectives) {
|
|
19377
|
+
const expressions = [];
|
|
19378
|
+
let hasForwardRef = false;
|
|
19379
|
+
for (const current of hostDirectives) {
|
|
19380
|
+
// Use a shorthand if there are no inputs or outputs.
|
|
19381
|
+
if (!current.inputs && !current.outputs) {
|
|
19382
|
+
expressions.push(current.directive.type);
|
|
19383
|
+
}
|
|
19384
|
+
else {
|
|
19385
|
+
const keys = [{ key: 'directive', value: current.directive.type, quoted: false }];
|
|
19386
|
+
if (current.inputs) {
|
|
19387
|
+
const inputsLiteral = createHostDirectivesMappingArray(current.inputs);
|
|
19388
|
+
if (inputsLiteral) {
|
|
19389
|
+
keys.push({ key: 'inputs', value: inputsLiteral, quoted: false });
|
|
19390
|
+
}
|
|
19391
|
+
}
|
|
19392
|
+
if (current.outputs) {
|
|
19393
|
+
const outputsLiteral = createHostDirectivesMappingArray(current.outputs);
|
|
19394
|
+
if (outputsLiteral) {
|
|
19395
|
+
keys.push({ key: 'outputs', value: outputsLiteral, quoted: false });
|
|
19396
|
+
}
|
|
19397
|
+
}
|
|
19398
|
+
expressions.push(literalMap(keys));
|
|
19399
|
+
}
|
|
19400
|
+
if (current.isForwardReference) {
|
|
19401
|
+
hasForwardRef = true;
|
|
19402
|
+
}
|
|
19403
|
+
}
|
|
19404
|
+
// If there's a forward reference, we generate a `function() { return [HostDir] }`,
|
|
19405
|
+
// otherwise we can save some bytes by using a plain array, e.g. `[HostDir]`.
|
|
19406
|
+
return hasForwardRef ?
|
|
19407
|
+
new FunctionExpr([], [new ReturnStatement(literalArr(expressions))]) :
|
|
19408
|
+
literalArr(expressions);
|
|
19409
|
+
}
|
|
19410
|
+
/**
|
|
19411
|
+
* Converts an input/output mapping object literal into an array where the even keys are the
|
|
19412
|
+
* public name of the binding and the odd ones are the name it was aliased to. E.g.
|
|
19413
|
+
* `{inputOne: 'aliasOne', inputTwo: 'aliasTwo'}` will become
|
|
19414
|
+
* `['inputOne', 'aliasOne', 'inputTwo', 'aliasTwo']`.
|
|
19415
|
+
*
|
|
19416
|
+
* This conversion is necessary, because hosts bind to the public name of the host directive and
|
|
19417
|
+
* keeping the mapping in an object literal will break for apps using property renaming.
|
|
19418
|
+
*/
|
|
19419
|
+
function createHostDirectivesMappingArray(mapping) {
|
|
19420
|
+
const elements = [];
|
|
19421
|
+
for (const publicName in mapping) {
|
|
19422
|
+
if (mapping.hasOwnProperty(publicName)) {
|
|
19423
|
+
elements.push(literal(publicName), literal(mapping[publicName]));
|
|
19424
|
+
}
|
|
19425
|
+
}
|
|
19426
|
+
return elements.length > 0 ? literalArr(elements) : null;
|
|
19427
|
+
}
|
|
19352
19428
|
|
|
19353
19429
|
/**
|
|
19354
19430
|
* @license
|
|
@@ -19630,6 +19706,7 @@ function convertDirectiveFacadeToMetadata(facade) {
|
|
|
19630
19706
|
providers: facade.providers != null ? new WrappedNodeExpr(facade.providers) : null,
|
|
19631
19707
|
viewQueries: facade.viewQueries.map(convertToR3QueryMetadata),
|
|
19632
19708
|
fullInheritance: false,
|
|
19709
|
+
hostDirectives: convertHostDirectivesToMetadata(facade),
|
|
19633
19710
|
};
|
|
19634
19711
|
}
|
|
19635
19712
|
function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
@@ -19653,6 +19730,7 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
|
19653
19730
|
typeArgumentCount: 0,
|
|
19654
19731
|
fullInheritance: false,
|
|
19655
19732
|
isStandalone: declaration.isStandalone ?? false,
|
|
19733
|
+
hostDirectives: convertHostDirectivesToMetadata(declaration),
|
|
19656
19734
|
};
|
|
19657
19735
|
}
|
|
19658
19736
|
function convertHostDeclarationToMetadata(host = {}) {
|
|
@@ -19666,6 +19744,26 @@ function convertHostDeclarationToMetadata(host = {}) {
|
|
|
19666
19744
|
},
|
|
19667
19745
|
};
|
|
19668
19746
|
}
|
|
19747
|
+
function convertHostDirectivesToMetadata(metadata) {
|
|
19748
|
+
if (metadata.hostDirectives?.length) {
|
|
19749
|
+
return metadata.hostDirectives.map(hostDirective => {
|
|
19750
|
+
return typeof hostDirective === 'function' ?
|
|
19751
|
+
{
|
|
19752
|
+
directive: wrapReference(hostDirective),
|
|
19753
|
+
inputs: null,
|
|
19754
|
+
outputs: null,
|
|
19755
|
+
isForwardReference: false
|
|
19756
|
+
} :
|
|
19757
|
+
{
|
|
19758
|
+
directive: wrapReference(hostDirective.directive),
|
|
19759
|
+
isForwardReference: false,
|
|
19760
|
+
inputs: hostDirective.inputs ? parseInputOutputs(hostDirective.inputs) : null,
|
|
19761
|
+
outputs: hostDirective.outputs ? parseInputOutputs(hostDirective.outputs) : null,
|
|
19762
|
+
};
|
|
19763
|
+
});
|
|
19764
|
+
}
|
|
19765
|
+
return null;
|
|
19766
|
+
}
|
|
19669
19767
|
function convertOpaqueValuesToExpressions(obj) {
|
|
19670
19768
|
const result = {};
|
|
19671
19769
|
for (const key of Object.keys(obj)) {
|
|
@@ -19896,7 +19994,7 @@ function publishFacade(global) {
|
|
|
19896
19994
|
* Use of this source code is governed by an MIT-style license that can be
|
|
19897
19995
|
* found in the LICENSE file at https://angular.io/license
|
|
19898
19996
|
*/
|
|
19899
|
-
const VERSION = new Version('
|
|
19997
|
+
const VERSION = new Version('15.0.0-next.0');
|
|
19900
19998
|
|
|
19901
19999
|
/**
|
|
19902
20000
|
* @license
|
|
@@ -21598,7 +21696,7 @@ class DirectiveBinder {
|
|
|
21598
21696
|
const cssSelector = createCssSelector(elementName, getAttrsForDirectiveMatching(node));
|
|
21599
21697
|
// Next, use the `SelectorMatcher` to get the list of directives on the node.
|
|
21600
21698
|
const directives = [];
|
|
21601
|
-
this.matcher.match(cssSelector, (
|
|
21699
|
+
this.matcher.match(cssSelector, (_selector, results) => directives.push(...results));
|
|
21602
21700
|
if (directives.length > 0) {
|
|
21603
21701
|
this.directives.set(node, directives);
|
|
21604
21702
|
}
|
|
@@ -21929,7 +22027,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
|
|
|
21929
22027
|
function compileDeclareClassMetadata(metadata) {
|
|
21930
22028
|
const definitionMap = new DefinitionMap();
|
|
21931
22029
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
21932
|
-
definitionMap.set('version', literal('
|
|
22030
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
21933
22031
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21934
22032
|
definitionMap.set('type', metadata.type);
|
|
21935
22033
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -22046,7 +22144,7 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
22046
22144
|
function createDirectiveDefinitionMap(meta) {
|
|
22047
22145
|
const definitionMap = new DefinitionMap();
|
|
22048
22146
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
22049
|
-
definitionMap.set('version', literal('
|
|
22147
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22050
22148
|
// e.g. `type: MyDirective`
|
|
22051
22149
|
definitionMap.set('type', meta.internalType);
|
|
22052
22150
|
if (meta.isStandalone) {
|
|
@@ -22075,6 +22173,9 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
22075
22173
|
if (meta.lifecycle.usesOnChanges) {
|
|
22076
22174
|
definitionMap.set('usesOnChanges', literal(true));
|
|
22077
22175
|
}
|
|
22176
|
+
if (meta.hostDirectives?.length) {
|
|
22177
|
+
definitionMap.set('hostDirectives', createHostDirectives(meta.hostDirectives));
|
|
22178
|
+
}
|
|
22078
22179
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22079
22180
|
return definitionMap;
|
|
22080
22181
|
}
|
|
@@ -22129,6 +22230,28 @@ function compileHostMetadata(meta) {
|
|
|
22129
22230
|
return null;
|
|
22130
22231
|
}
|
|
22131
22232
|
}
|
|
22233
|
+
function createHostDirectives(hostDirectives) {
|
|
22234
|
+
const expressions = hostDirectives.map(current => {
|
|
22235
|
+
const keys = [{
|
|
22236
|
+
key: 'directive',
|
|
22237
|
+
value: current.isForwardReference ? generateForwardRef(current.directive.type) :
|
|
22238
|
+
current.directive.type,
|
|
22239
|
+
quoted: false
|
|
22240
|
+
}];
|
|
22241
|
+
const inputsLiteral = current.inputs ? createHostDirectivesMappingArray(current.inputs) : null;
|
|
22242
|
+
const outputsLiteral = current.outputs ? createHostDirectivesMappingArray(current.outputs) : null;
|
|
22243
|
+
if (inputsLiteral) {
|
|
22244
|
+
keys.push({ key: 'inputs', value: inputsLiteral, quoted: false });
|
|
22245
|
+
}
|
|
22246
|
+
if (outputsLiteral) {
|
|
22247
|
+
keys.push({ key: 'outputs', value: outputsLiteral, quoted: false });
|
|
22248
|
+
}
|
|
22249
|
+
return literalMap(keys);
|
|
22250
|
+
});
|
|
22251
|
+
// If there's a forward reference, we generate a `function() { return [{directive: HostDir}] }`,
|
|
22252
|
+
// otherwise we can save some bytes by using a plain array, e.g. `[{directive: HostDir}]`.
|
|
22253
|
+
return literalArr(expressions);
|
|
22254
|
+
}
|
|
22132
22255
|
|
|
22133
22256
|
/**
|
|
22134
22257
|
* @license
|
|
@@ -22260,7 +22383,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
22260
22383
|
function compileDeclareFactoryFunction(meta) {
|
|
22261
22384
|
const definitionMap = new DefinitionMap();
|
|
22262
22385
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
22263
|
-
definitionMap.set('version', literal('
|
|
22386
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22264
22387
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22265
22388
|
definitionMap.set('type', meta.internalType);
|
|
22266
22389
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -22302,7 +22425,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
22302
22425
|
function createInjectableDefinitionMap(meta) {
|
|
22303
22426
|
const definitionMap = new DefinitionMap();
|
|
22304
22427
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
22305
|
-
definitionMap.set('version', literal('
|
|
22428
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22306
22429
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22307
22430
|
definitionMap.set('type', meta.internalType);
|
|
22308
22431
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -22360,7 +22483,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
22360
22483
|
function createInjectorDefinitionMap(meta) {
|
|
22361
22484
|
const definitionMap = new DefinitionMap();
|
|
22362
22485
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
22363
|
-
definitionMap.set('version', literal('
|
|
22486
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22364
22487
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22365
22488
|
definitionMap.set('type', meta.internalType);
|
|
22366
22489
|
definitionMap.set('providers', meta.providers);
|
|
@@ -22397,7 +22520,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
|
|
|
22397
22520
|
function createNgModuleDefinitionMap(meta) {
|
|
22398
22521
|
const definitionMap = new DefinitionMap();
|
|
22399
22522
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
22400
|
-
definitionMap.set('version', literal('
|
|
22523
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22401
22524
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22402
22525
|
definitionMap.set('type', meta.internalType);
|
|
22403
22526
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -22455,7 +22578,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
22455
22578
|
function createPipeDefinitionMap(meta) {
|
|
22456
22579
|
const definitionMap = new DefinitionMap();
|
|
22457
22580
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
22458
|
-
definitionMap.set('version', literal('
|
|
22581
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22459
22582
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22460
22583
|
// e.g. `type: MyPipe`
|
|
22461
22584
|
definitionMap.set('type', meta.internalType);
|