@angular/compiler 14.2.0 → 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/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/version.mjs +1 -1
- package/fesm2015/compiler.mjs +133 -15
- package/fesm2015/compiler.mjs.map +1 -1
- package/fesm2015/testing.mjs +1 -1
- package/fesm2020/compiler.mjs +129 -14
- 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',
|
|
@@ -18829,6 +18830,9 @@ function addFeatures(definitionMap, meta) {
|
|
|
18829
18830
|
if (meta.hasOwnProperty('template') && meta.isStandalone) {
|
|
18830
18831
|
features.push(importExpr(Identifiers.StandaloneFeature));
|
|
18831
18832
|
}
|
|
18833
|
+
if (meta.hostDirectives?.length) {
|
|
18834
|
+
features.push(importExpr(Identifiers.HostDirectivesFeature).callFn([createHostDirectivesFeatureArg(meta.hostDirectives)]));
|
|
18835
|
+
}
|
|
18832
18836
|
if (features.length) {
|
|
18833
18837
|
definitionMap.set('features', literalArr(features));
|
|
18834
18838
|
}
|
|
@@ -18941,6 +18945,7 @@ function createComponentType(meta) {
|
|
|
18941
18945
|
const typeParams = createBaseDirectiveTypeParams(meta);
|
|
18942
18946
|
typeParams.push(stringArrayAsType(meta.template.ngContentSelectors));
|
|
18943
18947
|
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
18948
|
+
typeParams.push(createHostDirectivesType(meta));
|
|
18944
18949
|
return expressionType(importExpr(Identifiers.ComponentDeclaration, typeParams));
|
|
18945
18950
|
}
|
|
18946
18951
|
/**
|
|
@@ -19016,7 +19021,7 @@ function createContentQueriesFunction(queries, constantPool, name) {
|
|
|
19016
19021
|
function stringAsType(str) {
|
|
19017
19022
|
return expressionType(literal(str));
|
|
19018
19023
|
}
|
|
19019
|
-
function
|
|
19024
|
+
function stringMapAsLiteralExpression(map) {
|
|
19020
19025
|
const mapValues = Object.keys(map).map(key => {
|
|
19021
19026
|
const value = Array.isArray(map[key]) ? map[key][0] : map[key];
|
|
19022
19027
|
return {
|
|
@@ -19025,7 +19030,7 @@ function stringMapAsType(map) {
|
|
|
19025
19030
|
quoted: true,
|
|
19026
19031
|
};
|
|
19027
19032
|
});
|
|
19028
|
-
return
|
|
19033
|
+
return literalMap(mapValues);
|
|
19029
19034
|
}
|
|
19030
19035
|
function stringArrayAsType(arr) {
|
|
19031
19036
|
return arr.length > 0 ? expressionType(literalArr(arr.map(value => literal(value)))) :
|
|
@@ -19039,8 +19044,8 @@ function createBaseDirectiveTypeParams(meta) {
|
|
|
19039
19044
|
typeWithParameters(meta.type.type, meta.typeArgumentCount),
|
|
19040
19045
|
selectorForType !== null ? stringAsType(selectorForType) : NONE_TYPE,
|
|
19041
19046
|
meta.exportAs !== null ? stringArrayAsType(meta.exportAs) : NONE_TYPE,
|
|
19042
|
-
|
|
19043
|
-
|
|
19047
|
+
expressionType(stringMapAsLiteralExpression(meta.inputs)),
|
|
19048
|
+
expressionType(stringMapAsLiteralExpression(meta.outputs)),
|
|
19044
19049
|
stringArrayAsType(meta.queries.map(q => q.propertyName)),
|
|
19045
19050
|
];
|
|
19046
19051
|
}
|
|
@@ -19054,6 +19059,7 @@ function createDirectiveType(meta) {
|
|
|
19054
19059
|
// so that future fields align.
|
|
19055
19060
|
typeParams.push(NONE_TYPE);
|
|
19056
19061
|
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
19062
|
+
typeParams.push(createHostDirectivesType(meta));
|
|
19057
19063
|
return expressionType(importExpr(Identifiers.DirectiveDeclaration, typeParams));
|
|
19058
19064
|
}
|
|
19059
19065
|
// Define and update any view queries
|
|
@@ -19357,6 +19363,68 @@ function compileStyles(styles, selector, hostSelector) {
|
|
|
19357
19363
|
return shadowCss.shimCssText(style, selector, hostSelector);
|
|
19358
19364
|
});
|
|
19359
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
|
+
}
|
|
19360
19428
|
|
|
19361
19429
|
/**
|
|
19362
19430
|
* @license
|
|
@@ -19638,6 +19706,7 @@ function convertDirectiveFacadeToMetadata(facade) {
|
|
|
19638
19706
|
providers: facade.providers != null ? new WrappedNodeExpr(facade.providers) : null,
|
|
19639
19707
|
viewQueries: facade.viewQueries.map(convertToR3QueryMetadata),
|
|
19640
19708
|
fullInheritance: false,
|
|
19709
|
+
hostDirectives: convertHostDirectivesToMetadata(facade),
|
|
19641
19710
|
};
|
|
19642
19711
|
}
|
|
19643
19712
|
function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
@@ -19661,6 +19730,7 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
|
19661
19730
|
typeArgumentCount: 0,
|
|
19662
19731
|
fullInheritance: false,
|
|
19663
19732
|
isStandalone: declaration.isStandalone ?? false,
|
|
19733
|
+
hostDirectives: convertHostDirectivesToMetadata(declaration),
|
|
19664
19734
|
};
|
|
19665
19735
|
}
|
|
19666
19736
|
function convertHostDeclarationToMetadata(host = {}) {
|
|
@@ -19674,6 +19744,26 @@ function convertHostDeclarationToMetadata(host = {}) {
|
|
|
19674
19744
|
},
|
|
19675
19745
|
};
|
|
19676
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
|
+
}
|
|
19677
19767
|
function convertOpaqueValuesToExpressions(obj) {
|
|
19678
19768
|
const result = {};
|
|
19679
19769
|
for (const key of Object.keys(obj)) {
|
|
@@ -19904,7 +19994,7 @@ function publishFacade(global) {
|
|
|
19904
19994
|
* Use of this source code is governed by an MIT-style license that can be
|
|
19905
19995
|
* found in the LICENSE file at https://angular.io/license
|
|
19906
19996
|
*/
|
|
19907
|
-
const VERSION = new Version('
|
|
19997
|
+
const VERSION = new Version('15.0.0-next.0');
|
|
19908
19998
|
|
|
19909
19999
|
/**
|
|
19910
20000
|
* @license
|
|
@@ -21606,7 +21696,7 @@ class DirectiveBinder {
|
|
|
21606
21696
|
const cssSelector = createCssSelector(elementName, getAttrsForDirectiveMatching(node));
|
|
21607
21697
|
// Next, use the `SelectorMatcher` to get the list of directives on the node.
|
|
21608
21698
|
const directives = [];
|
|
21609
|
-
this.matcher.match(cssSelector, (
|
|
21699
|
+
this.matcher.match(cssSelector, (_selector, results) => directives.push(...results));
|
|
21610
21700
|
if (directives.length > 0) {
|
|
21611
21701
|
this.directives.set(node, directives);
|
|
21612
21702
|
}
|
|
@@ -21937,7 +22027,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
|
|
|
21937
22027
|
function compileDeclareClassMetadata(metadata) {
|
|
21938
22028
|
const definitionMap = new DefinitionMap();
|
|
21939
22029
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
21940
|
-
definitionMap.set('version', literal('
|
|
22030
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
21941
22031
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21942
22032
|
definitionMap.set('type', metadata.type);
|
|
21943
22033
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -22054,7 +22144,7 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
22054
22144
|
function createDirectiveDefinitionMap(meta) {
|
|
22055
22145
|
const definitionMap = new DefinitionMap();
|
|
22056
22146
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
22057
|
-
definitionMap.set('version', literal('
|
|
22147
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22058
22148
|
// e.g. `type: MyDirective`
|
|
22059
22149
|
definitionMap.set('type', meta.internalType);
|
|
22060
22150
|
if (meta.isStandalone) {
|
|
@@ -22083,6 +22173,9 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
22083
22173
|
if (meta.lifecycle.usesOnChanges) {
|
|
22084
22174
|
definitionMap.set('usesOnChanges', literal(true));
|
|
22085
22175
|
}
|
|
22176
|
+
if (meta.hostDirectives?.length) {
|
|
22177
|
+
definitionMap.set('hostDirectives', createHostDirectives(meta.hostDirectives));
|
|
22178
|
+
}
|
|
22086
22179
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22087
22180
|
return definitionMap;
|
|
22088
22181
|
}
|
|
@@ -22137,6 +22230,28 @@ function compileHostMetadata(meta) {
|
|
|
22137
22230
|
return null;
|
|
22138
22231
|
}
|
|
22139
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
|
+
}
|
|
22140
22255
|
|
|
22141
22256
|
/**
|
|
22142
22257
|
* @license
|
|
@@ -22268,7 +22383,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
22268
22383
|
function compileDeclareFactoryFunction(meta) {
|
|
22269
22384
|
const definitionMap = new DefinitionMap();
|
|
22270
22385
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
22271
|
-
definitionMap.set('version', literal('
|
|
22386
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22272
22387
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22273
22388
|
definitionMap.set('type', meta.internalType);
|
|
22274
22389
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -22310,7 +22425,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
22310
22425
|
function createInjectableDefinitionMap(meta) {
|
|
22311
22426
|
const definitionMap = new DefinitionMap();
|
|
22312
22427
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
22313
|
-
definitionMap.set('version', literal('
|
|
22428
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22314
22429
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22315
22430
|
definitionMap.set('type', meta.internalType);
|
|
22316
22431
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -22368,7 +22483,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
22368
22483
|
function createInjectorDefinitionMap(meta) {
|
|
22369
22484
|
const definitionMap = new DefinitionMap();
|
|
22370
22485
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
22371
|
-
definitionMap.set('version', literal('
|
|
22486
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22372
22487
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22373
22488
|
definitionMap.set('type', meta.internalType);
|
|
22374
22489
|
definitionMap.set('providers', meta.providers);
|
|
@@ -22405,7 +22520,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
|
|
|
22405
22520
|
function createNgModuleDefinitionMap(meta) {
|
|
22406
22521
|
const definitionMap = new DefinitionMap();
|
|
22407
22522
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
22408
|
-
definitionMap.set('version', literal('
|
|
22523
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22409
22524
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22410
22525
|
definitionMap.set('type', meta.internalType);
|
|
22411
22526
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -22463,7 +22578,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
22463
22578
|
function createPipeDefinitionMap(meta) {
|
|
22464
22579
|
const definitionMap = new DefinitionMap();
|
|
22465
22580
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
22466
|
-
definitionMap.set('version', literal('
|
|
22581
|
+
definitionMap.set('version', literal('15.0.0-next.0'));
|
|
22467
22582
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22468
22583
|
// e.g. `type: MyPipe`
|
|
22469
22584
|
definitionMap.set('type', meta.internalType);
|