@angular/compiler 16.0.0-next.2 → 16.0.0-next.4
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/core.mjs +1 -1
- package/esm2020/src/jit_compiler_facade.mjs +46 -12
- package/esm2020/src/render3/partial/class_metadata.mjs +1 -1
- package/esm2020/src/render3/partial/directive.mjs +5 -5
- 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/view/api.mjs +1 -1
- package/esm2020/src/render3/view/compiler.mjs +19 -6
- package/esm2020/src/render3/view/util.mjs +15 -15
- package/esm2020/src/version.mjs +1 -1
- package/fesm2015/compiler.mjs +94 -47
- package/fesm2015/compiler.mjs.map +1 -1
- package/fesm2015/testing.mjs +1 -1
- package/fesm2020/compiler.mjs +86 -39
- package/fesm2020/compiler.mjs.map +1 -1
- package/fesm2020/testing.mjs +1 -1
- package/index.d.ts +14 -4
- 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 v16.0.0-next.
|
|
2
|
+
* @license Angular v16.0.0-next.4
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -4710,30 +4710,30 @@ function asLiteral(value) {
|
|
|
4710
4710
|
}
|
|
4711
4711
|
return literal(value, INFERRED_TYPE);
|
|
4712
4712
|
}
|
|
4713
|
-
function
|
|
4714
|
-
|
|
4715
|
-
|
|
4713
|
+
function conditionallyCreateDirectiveBindingLiteral(map, keepDeclared) {
|
|
4714
|
+
const keys = Object.getOwnPropertyNames(map);
|
|
4715
|
+
if (keys.length === 0) {
|
|
4716
|
+
return null;
|
|
4716
4717
|
}
|
|
4717
|
-
return
|
|
4718
|
-
}
|
|
4719
|
-
function mapToExpression(map, keepDeclared) {
|
|
4720
|
-
return literalMap(Object.getOwnPropertyNames(map).map(key => {
|
|
4721
|
-
// canonical syntax: `dirProp: publicProp`
|
|
4718
|
+
return literalMap(keys.map(key => {
|
|
4722
4719
|
const value = map[key];
|
|
4723
4720
|
let declaredName;
|
|
4724
4721
|
let publicName;
|
|
4725
4722
|
let minifiedName;
|
|
4726
4723
|
let needsDeclaredName;
|
|
4727
|
-
if (
|
|
4728
|
-
|
|
4724
|
+
if (typeof value === 'string') {
|
|
4725
|
+
// canonical syntax: `dirProp: publicProp`
|
|
4726
|
+
declaredName = key;
|
|
4729
4727
|
minifiedName = key;
|
|
4730
|
-
needsDeclaredName = publicName !== declaredName;
|
|
4731
|
-
}
|
|
4732
|
-
else {
|
|
4733
|
-
minifiedName = declaredName = key;
|
|
4734
4728
|
publicName = value;
|
|
4735
4729
|
needsDeclaredName = false;
|
|
4736
4730
|
}
|
|
4731
|
+
else {
|
|
4732
|
+
minifiedName = key;
|
|
4733
|
+
declaredName = value.classPropertyName;
|
|
4734
|
+
publicName = value.bindingPropertyName;
|
|
4735
|
+
needsDeclaredName = publicName !== declaredName;
|
|
4736
|
+
}
|
|
4737
4737
|
return {
|
|
4738
4738
|
key: minifiedName,
|
|
4739
4739
|
// put quotes around keys that contain potentially unsafe characters
|
|
@@ -18686,9 +18686,9 @@ function baseDirectiveFields(meta, constantPool, bindingParser) {
|
|
|
18686
18686
|
// e.g. `hostBindings: (rf, ctx) => { ... }
|
|
18687
18687
|
definitionMap.set('hostBindings', createHostBindingsFunction(meta.host, meta.typeSourceSpan, bindingParser, constantPool, meta.selector || '', meta.name, definitionMap));
|
|
18688
18688
|
// e.g 'inputs: {a: 'a'}`
|
|
18689
|
-
definitionMap.set('inputs',
|
|
18689
|
+
definitionMap.set('inputs', conditionallyCreateDirectiveBindingLiteral(meta.inputs, true));
|
|
18690
18690
|
// e.g 'outputs: {a: 'a'}`
|
|
18691
|
-
definitionMap.set('outputs',
|
|
18691
|
+
definitionMap.set('outputs', conditionallyCreateDirectiveBindingLiteral(meta.outputs));
|
|
18692
18692
|
if (meta.exportAs !== null) {
|
|
18693
18693
|
definitionMap.set('exportAs', literalArr(meta.exportAs.map(e => literal(e))));
|
|
18694
18694
|
}
|
|
@@ -18939,11 +18939,24 @@ function createBaseDirectiveTypeParams(meta) {
|
|
|
18939
18939
|
typeWithParameters(meta.type.type, meta.typeArgumentCount),
|
|
18940
18940
|
selectorForType !== null ? stringAsType(selectorForType) : NONE_TYPE,
|
|
18941
18941
|
meta.exportAs !== null ? stringArrayAsType(meta.exportAs) : NONE_TYPE,
|
|
18942
|
-
expressionType(
|
|
18942
|
+
expressionType(getInputsTypeExpression(meta)),
|
|
18943
18943
|
expressionType(stringMapAsLiteralExpression(meta.outputs)),
|
|
18944
18944
|
stringArrayAsType(meta.queries.map(q => q.propertyName)),
|
|
18945
18945
|
];
|
|
18946
18946
|
}
|
|
18947
|
+
function getInputsTypeExpression(meta) {
|
|
18948
|
+
return literalMap(Object.keys(meta.inputs).map(key => {
|
|
18949
|
+
const value = meta.inputs[key];
|
|
18950
|
+
return {
|
|
18951
|
+
key,
|
|
18952
|
+
value: literalMap([
|
|
18953
|
+
{ key: 'alias', value: literal(value.bindingPropertyName), quoted: true },
|
|
18954
|
+
{ key: 'required', value: literal(value.required), quoted: true }
|
|
18955
|
+
]),
|
|
18956
|
+
quoted: true
|
|
18957
|
+
};
|
|
18958
|
+
}));
|
|
18959
|
+
}
|
|
18947
18960
|
/**
|
|
18948
18961
|
* Creates the type specification from the directive meta. This type is inserted into .d.ts files
|
|
18949
18962
|
* to be consumed by upstream compilations.
|
|
@@ -19569,8 +19582,8 @@ function convertQueryPredicate(predicate) {
|
|
|
19569
19582
|
createMayBeForwardRefExpression(new WrappedNodeExpr(predicate), 1 /* ForwardRefHandling.Wrapped */);
|
|
19570
19583
|
}
|
|
19571
19584
|
function convertDirectiveFacadeToMetadata(facade) {
|
|
19572
|
-
const inputsFromMetadata =
|
|
19573
|
-
const outputsFromMetadata =
|
|
19585
|
+
const inputsFromMetadata = parseInputsArray(facade.inputs || []);
|
|
19586
|
+
const outputsFromMetadata = parseMappingStringArray(facade.outputs || []);
|
|
19574
19587
|
const propMetadata = facade.propMetadata;
|
|
19575
19588
|
const inputsFromType = {};
|
|
19576
19589
|
const outputsFromType = {};
|
|
@@ -19578,11 +19591,14 @@ function convertDirectiveFacadeToMetadata(facade) {
|
|
|
19578
19591
|
if (propMetadata.hasOwnProperty(field)) {
|
|
19579
19592
|
propMetadata[field].forEach(ann => {
|
|
19580
19593
|
if (isInput(ann)) {
|
|
19581
|
-
inputsFromType[field] =
|
|
19582
|
-
|
|
19594
|
+
inputsFromType[field] = {
|
|
19595
|
+
bindingPropertyName: ann.alias || field,
|
|
19596
|
+
classPropertyName: field,
|
|
19597
|
+
required: ann.required || false
|
|
19598
|
+
};
|
|
19583
19599
|
}
|
|
19584
19600
|
else if (isOutput(ann)) {
|
|
19585
|
-
outputsFromType[field] = ann.
|
|
19601
|
+
outputsFromType[field] = ann.alias || field;
|
|
19586
19602
|
}
|
|
19587
19603
|
});
|
|
19588
19604
|
}
|
|
@@ -19611,7 +19627,7 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
|
19611
19627
|
typeSourceSpan,
|
|
19612
19628
|
internalType: new WrappedNodeExpr(declaration.type),
|
|
19613
19629
|
selector: declaration.selector ?? null,
|
|
19614
|
-
inputs: declaration.inputs
|
|
19630
|
+
inputs: declaration.inputs ? inputsMappingToInputMetadata(declaration.inputs) : {},
|
|
19615
19631
|
outputs: declaration.outputs ?? {},
|
|
19616
19632
|
host: convertHostDeclarationToMetadata(declaration.host),
|
|
19617
19633
|
queries: (declaration.queries ?? []).map(convertQueryDeclarationToMetadata),
|
|
@@ -19652,8 +19668,8 @@ function convertHostDirectivesToMetadata(metadata) {
|
|
|
19652
19668
|
{
|
|
19653
19669
|
directive: wrapReference(hostDirective.directive),
|
|
19654
19670
|
isForwardReference: false,
|
|
19655
|
-
inputs: hostDirective.inputs ?
|
|
19656
|
-
outputs: hostDirective.outputs ?
|
|
19671
|
+
inputs: hostDirective.inputs ? parseMappingStringArray(hostDirective.inputs) : null,
|
|
19672
|
+
outputs: hostDirective.outputs ? parseMappingStringArray(hostDirective.outputs) : null,
|
|
19657
19673
|
};
|
|
19658
19674
|
});
|
|
19659
19675
|
}
|
|
@@ -19845,13 +19861,44 @@ function isInput(value) {
|
|
|
19845
19861
|
function isOutput(value) {
|
|
19846
19862
|
return value.ngMetadataName === 'Output';
|
|
19847
19863
|
}
|
|
19848
|
-
function
|
|
19864
|
+
function inputsMappingToInputMetadata(inputs) {
|
|
19865
|
+
return Object.keys(inputs).reduce((result, key) => {
|
|
19866
|
+
const value = inputs[key];
|
|
19867
|
+
result[key] = typeof value === 'string' ?
|
|
19868
|
+
{ bindingPropertyName: value, classPropertyName: value, required: false } :
|
|
19869
|
+
{ bindingPropertyName: value[0], classPropertyName: value[1], required: false };
|
|
19870
|
+
return result;
|
|
19871
|
+
}, {});
|
|
19872
|
+
}
|
|
19873
|
+
function parseInputsArray(values) {
|
|
19849
19874
|
return values.reduce((results, value) => {
|
|
19850
|
-
|
|
19851
|
-
|
|
19875
|
+
if (typeof value === 'string') {
|
|
19876
|
+
const [bindingPropertyName, classPropertyName] = parseMappingString(value);
|
|
19877
|
+
results[classPropertyName] = { bindingPropertyName, classPropertyName, required: false };
|
|
19878
|
+
}
|
|
19879
|
+
else {
|
|
19880
|
+
results[value.name] = {
|
|
19881
|
+
bindingPropertyName: value.alias || value.name,
|
|
19882
|
+
classPropertyName: value.name,
|
|
19883
|
+
required: value.required || false
|
|
19884
|
+
};
|
|
19885
|
+
}
|
|
19852
19886
|
return results;
|
|
19853
19887
|
}, {});
|
|
19854
19888
|
}
|
|
19889
|
+
function parseMappingStringArray(values) {
|
|
19890
|
+
return values.reduce((results, value) => {
|
|
19891
|
+
const [alias, fieldName] = parseMappingString(value);
|
|
19892
|
+
results[fieldName] = alias;
|
|
19893
|
+
return results;
|
|
19894
|
+
}, {});
|
|
19895
|
+
}
|
|
19896
|
+
function parseMappingString(value) {
|
|
19897
|
+
// Either the value is 'field' or 'field: property'. In the first case, `property` will
|
|
19898
|
+
// be undefined, in which case the field name should also be used as the property name.
|
|
19899
|
+
const [fieldName, bindingPropertyName] = value.split(':', 2).map(str => str.trim());
|
|
19900
|
+
return [bindingPropertyName ?? fieldName, fieldName];
|
|
19901
|
+
}
|
|
19855
19902
|
function convertDeclarePipeFacadeToMetadata(declaration) {
|
|
19856
19903
|
return {
|
|
19857
19904
|
name: declaration.type.name,
|
|
@@ -19887,7 +19934,7 @@ function publishFacade(global) {
|
|
|
19887
19934
|
* @description
|
|
19888
19935
|
* Entry point for all public APIs of the compiler package.
|
|
19889
19936
|
*/
|
|
19890
|
-
const VERSION = new Version('16.0.0-next.
|
|
19937
|
+
const VERSION = new Version('16.0.0-next.4');
|
|
19891
19938
|
|
|
19892
19939
|
class CompilerConfig {
|
|
19893
19940
|
constructor({ defaultEncapsulation = ViewEncapsulation.Emulated, useJit = true, missingTranslation = null, preserveWhitespaces, strictInjectionParameters } = {}) {
|
|
@@ -21811,7 +21858,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
|
|
|
21811
21858
|
function compileDeclareClassMetadata(metadata) {
|
|
21812
21859
|
const definitionMap = new DefinitionMap();
|
|
21813
21860
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
21814
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
21861
|
+
definitionMap.set('version', literal('16.0.0-next.4'));
|
|
21815
21862
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21816
21863
|
definitionMap.set('type', metadata.type);
|
|
21817
21864
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -21914,7 +21961,7 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
21914
21961
|
function createDirectiveDefinitionMap(meta) {
|
|
21915
21962
|
const definitionMap = new DefinitionMap();
|
|
21916
21963
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
21917
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
21964
|
+
definitionMap.set('version', literal('16.0.0-next.4'));
|
|
21918
21965
|
// e.g. `type: MyDirective`
|
|
21919
21966
|
definitionMap.set('type', meta.internalType);
|
|
21920
21967
|
if (meta.isStandalone) {
|
|
@@ -21924,8 +21971,8 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
21924
21971
|
if (meta.selector !== null) {
|
|
21925
21972
|
definitionMap.set('selector', literal(meta.selector));
|
|
21926
21973
|
}
|
|
21927
|
-
definitionMap.set('inputs',
|
|
21928
|
-
definitionMap.set('outputs',
|
|
21974
|
+
definitionMap.set('inputs', conditionallyCreateDirectiveBindingLiteral(meta.inputs, true));
|
|
21975
|
+
definitionMap.set('outputs', conditionallyCreateDirectiveBindingLiteral(meta.outputs));
|
|
21929
21976
|
definitionMap.set('host', compileHostMetadata(meta.host));
|
|
21930
21977
|
definitionMap.set('providers', meta.providers);
|
|
21931
21978
|
if (meta.queries.length > 0) {
|
|
@@ -22139,7 +22186,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
22139
22186
|
function compileDeclareFactoryFunction(meta) {
|
|
22140
22187
|
const definitionMap = new DefinitionMap();
|
|
22141
22188
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
22142
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22189
|
+
definitionMap.set('version', literal('16.0.0-next.4'));
|
|
22143
22190
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22144
22191
|
definitionMap.set('type', meta.internalType);
|
|
22145
22192
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -22174,7 +22221,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
22174
22221
|
function createInjectableDefinitionMap(meta) {
|
|
22175
22222
|
const definitionMap = new DefinitionMap();
|
|
22176
22223
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
22177
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22224
|
+
definitionMap.set('version', literal('16.0.0-next.4'));
|
|
22178
22225
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22179
22226
|
definitionMap.set('type', meta.internalType);
|
|
22180
22227
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -22225,7 +22272,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
22225
22272
|
function createInjectorDefinitionMap(meta) {
|
|
22226
22273
|
const definitionMap = new DefinitionMap();
|
|
22227
22274
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
22228
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22275
|
+
definitionMap.set('version', literal('16.0.0-next.4'));
|
|
22229
22276
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22230
22277
|
definitionMap.set('type', meta.internalType);
|
|
22231
22278
|
definitionMap.set('providers', meta.providers);
|
|
@@ -22255,7 +22302,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
|
|
|
22255
22302
|
function createNgModuleDefinitionMap(meta) {
|
|
22256
22303
|
const definitionMap = new DefinitionMap();
|
|
22257
22304
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
22258
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22305
|
+
definitionMap.set('version', literal('16.0.0-next.4'));
|
|
22259
22306
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22260
22307
|
definitionMap.set('type', meta.internalType);
|
|
22261
22308
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -22306,7 +22353,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
22306
22353
|
function createPipeDefinitionMap(meta) {
|
|
22307
22354
|
const definitionMap = new DefinitionMap();
|
|
22308
22355
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
22309
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22356
|
+
definitionMap.set('version', literal('16.0.0-next.4'));
|
|
22310
22357
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22311
22358
|
// e.g. `type: MyPipe`
|
|
22312
22359
|
definitionMap.set('type', meta.internalType);
|