@angular/compiler 16.0.0-next.2 → 16.0.0-next.3
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 +45 -11
- 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 +12 -6
- package/esm2020/src/render3/view/util.mjs +15 -15
- package/esm2020/src/version.mjs +1 -1
- package/fesm2015/compiler.mjs +86 -46
- package/fesm2015/compiler.mjs.map +1 -1
- package/fesm2015/testing.mjs +1 -1
- package/fesm2020/compiler.mjs +78 -38
- package/fesm2020/compiler.mjs.map +1 -1
- package/fesm2020/testing.mjs +1 -1
- package/index.d.ts +10 -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 v16.0.0-next.
|
|
2
|
+
* @license Angular v16.0.0-next.3
|
|
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,17 @@ 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
|
+
// TODO(required-inputs): expand this to generate the new object literal syntax.
|
|
18949
|
+
return literalMap(Object.keys(meta.inputs).map(key => {
|
|
18950
|
+
return { key, value: literal(meta.inputs[key].bindingPropertyName), quoted: true };
|
|
18951
|
+
}));
|
|
18952
|
+
}
|
|
18947
18953
|
/**
|
|
18948
18954
|
* Creates the type specification from the directive meta. This type is inserted into .d.ts files
|
|
18949
18955
|
* to be consumed by upstream compilations.
|
|
@@ -19569,8 +19575,8 @@ function convertQueryPredicate(predicate) {
|
|
|
19569
19575
|
createMayBeForwardRefExpression(new WrappedNodeExpr(predicate), 1 /* ForwardRefHandling.Wrapped */);
|
|
19570
19576
|
}
|
|
19571
19577
|
function convertDirectiveFacadeToMetadata(facade) {
|
|
19572
|
-
const inputsFromMetadata =
|
|
19573
|
-
const outputsFromMetadata =
|
|
19578
|
+
const inputsFromMetadata = parseInputsArray(facade.inputs || []);
|
|
19579
|
+
const outputsFromMetadata = parseMappingStringArray(facade.outputs || []);
|
|
19574
19580
|
const propMetadata = facade.propMetadata;
|
|
19575
19581
|
const inputsFromType = {};
|
|
19576
19582
|
const outputsFromType = {};
|
|
@@ -19578,8 +19584,11 @@ function convertDirectiveFacadeToMetadata(facade) {
|
|
|
19578
19584
|
if (propMetadata.hasOwnProperty(field)) {
|
|
19579
19585
|
propMetadata[field].forEach(ann => {
|
|
19580
19586
|
if (isInput(ann)) {
|
|
19581
|
-
|
|
19582
|
-
|
|
19587
|
+
// TODO(required-inputs): pass required flag
|
|
19588
|
+
inputsFromType[field] = {
|
|
19589
|
+
bindingPropertyName: ann.bindingPropertyName || field,
|
|
19590
|
+
classPropertyName: field
|
|
19591
|
+
};
|
|
19583
19592
|
}
|
|
19584
19593
|
else if (isOutput(ann)) {
|
|
19585
19594
|
outputsFromType[field] = ann.bindingPropertyName || field;
|
|
@@ -19611,7 +19620,7 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
|
19611
19620
|
typeSourceSpan,
|
|
19612
19621
|
internalType: new WrappedNodeExpr(declaration.type),
|
|
19613
19622
|
selector: declaration.selector ?? null,
|
|
19614
|
-
inputs: declaration.inputs
|
|
19623
|
+
inputs: declaration.inputs ? inputsMappingToInputMetadata(declaration.inputs) : {},
|
|
19615
19624
|
outputs: declaration.outputs ?? {},
|
|
19616
19625
|
host: convertHostDeclarationToMetadata(declaration.host),
|
|
19617
19626
|
queries: (declaration.queries ?? []).map(convertQueryDeclarationToMetadata),
|
|
@@ -19652,8 +19661,8 @@ function convertHostDirectivesToMetadata(metadata) {
|
|
|
19652
19661
|
{
|
|
19653
19662
|
directive: wrapReference(hostDirective.directive),
|
|
19654
19663
|
isForwardReference: false,
|
|
19655
|
-
inputs: hostDirective.inputs ?
|
|
19656
|
-
outputs: hostDirective.outputs ?
|
|
19664
|
+
inputs: hostDirective.inputs ? parseMappingStringArray(hostDirective.inputs) : null,
|
|
19665
|
+
outputs: hostDirective.outputs ? parseMappingStringArray(hostDirective.outputs) : null,
|
|
19657
19666
|
};
|
|
19658
19667
|
});
|
|
19659
19668
|
}
|
|
@@ -19845,13 +19854,44 @@ function isInput(value) {
|
|
|
19845
19854
|
function isOutput(value) {
|
|
19846
19855
|
return value.ngMetadataName === 'Output';
|
|
19847
19856
|
}
|
|
19848
|
-
function
|
|
19857
|
+
function inputsMappingToInputMetadata(inputs) {
|
|
19858
|
+
return Object.keys(inputs).reduce((result, key) => {
|
|
19859
|
+
const value = inputs[key];
|
|
19860
|
+
result[key] = typeof value === 'string' ?
|
|
19861
|
+
{ bindingPropertyName: value, classPropertyName: value } :
|
|
19862
|
+
{ bindingPropertyName: value[0], classPropertyName: value[1] };
|
|
19863
|
+
return result;
|
|
19864
|
+
}, {});
|
|
19865
|
+
}
|
|
19866
|
+
function parseInputsArray(values) {
|
|
19849
19867
|
return values.reduce((results, value) => {
|
|
19850
|
-
|
|
19851
|
-
|
|
19868
|
+
if (typeof value === 'string') {
|
|
19869
|
+
const [bindingPropertyName, classPropertyName] = parseMappingString(value);
|
|
19870
|
+
results[classPropertyName] = { bindingPropertyName, classPropertyName };
|
|
19871
|
+
}
|
|
19872
|
+
else {
|
|
19873
|
+
// TODO(required-inputs): pass required flag
|
|
19874
|
+
results[value.name] = {
|
|
19875
|
+
bindingPropertyName: value.alias || value.name,
|
|
19876
|
+
classPropertyName: value.name
|
|
19877
|
+
};
|
|
19878
|
+
}
|
|
19879
|
+
return results;
|
|
19880
|
+
}, {});
|
|
19881
|
+
}
|
|
19882
|
+
function parseMappingStringArray(values) {
|
|
19883
|
+
return values.reduce((results, value) => {
|
|
19884
|
+
const [publicName, fieldName] = parseMappingString(value);
|
|
19885
|
+
results[fieldName] = publicName;
|
|
19852
19886
|
return results;
|
|
19853
19887
|
}, {});
|
|
19854
19888
|
}
|
|
19889
|
+
function parseMappingString(value) {
|
|
19890
|
+
// Either the value is 'field' or 'field: property'. In the first case, `property` will
|
|
19891
|
+
// be undefined, in which case the field name should also be used as the property name.
|
|
19892
|
+
const [fieldName, bindingPropertyName] = value.split(':', 2).map(str => str.trim());
|
|
19893
|
+
return [bindingPropertyName ?? fieldName, fieldName];
|
|
19894
|
+
}
|
|
19855
19895
|
function convertDeclarePipeFacadeToMetadata(declaration) {
|
|
19856
19896
|
return {
|
|
19857
19897
|
name: declaration.type.name,
|
|
@@ -19887,7 +19927,7 @@ function publishFacade(global) {
|
|
|
19887
19927
|
* @description
|
|
19888
19928
|
* Entry point for all public APIs of the compiler package.
|
|
19889
19929
|
*/
|
|
19890
|
-
const VERSION = new Version('16.0.0-next.
|
|
19930
|
+
const VERSION = new Version('16.0.0-next.3');
|
|
19891
19931
|
|
|
19892
19932
|
class CompilerConfig {
|
|
19893
19933
|
constructor({ defaultEncapsulation = ViewEncapsulation.Emulated, useJit = true, missingTranslation = null, preserveWhitespaces, strictInjectionParameters } = {}) {
|
|
@@ -21811,7 +21851,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
|
|
|
21811
21851
|
function compileDeclareClassMetadata(metadata) {
|
|
21812
21852
|
const definitionMap = new DefinitionMap();
|
|
21813
21853
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
21814
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
21854
|
+
definitionMap.set('version', literal('16.0.0-next.3'));
|
|
21815
21855
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21816
21856
|
definitionMap.set('type', metadata.type);
|
|
21817
21857
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -21914,7 +21954,7 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
21914
21954
|
function createDirectiveDefinitionMap(meta) {
|
|
21915
21955
|
const definitionMap = new DefinitionMap();
|
|
21916
21956
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
21917
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
21957
|
+
definitionMap.set('version', literal('16.0.0-next.3'));
|
|
21918
21958
|
// e.g. `type: MyDirective`
|
|
21919
21959
|
definitionMap.set('type', meta.internalType);
|
|
21920
21960
|
if (meta.isStandalone) {
|
|
@@ -21924,8 +21964,8 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
21924
21964
|
if (meta.selector !== null) {
|
|
21925
21965
|
definitionMap.set('selector', literal(meta.selector));
|
|
21926
21966
|
}
|
|
21927
|
-
definitionMap.set('inputs',
|
|
21928
|
-
definitionMap.set('outputs',
|
|
21967
|
+
definitionMap.set('inputs', conditionallyCreateDirectiveBindingLiteral(meta.inputs, true));
|
|
21968
|
+
definitionMap.set('outputs', conditionallyCreateDirectiveBindingLiteral(meta.outputs));
|
|
21929
21969
|
definitionMap.set('host', compileHostMetadata(meta.host));
|
|
21930
21970
|
definitionMap.set('providers', meta.providers);
|
|
21931
21971
|
if (meta.queries.length > 0) {
|
|
@@ -22139,7 +22179,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
22139
22179
|
function compileDeclareFactoryFunction(meta) {
|
|
22140
22180
|
const definitionMap = new DefinitionMap();
|
|
22141
22181
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
22142
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22182
|
+
definitionMap.set('version', literal('16.0.0-next.3'));
|
|
22143
22183
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22144
22184
|
definitionMap.set('type', meta.internalType);
|
|
22145
22185
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -22174,7 +22214,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
22174
22214
|
function createInjectableDefinitionMap(meta) {
|
|
22175
22215
|
const definitionMap = new DefinitionMap();
|
|
22176
22216
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
22177
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22217
|
+
definitionMap.set('version', literal('16.0.0-next.3'));
|
|
22178
22218
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22179
22219
|
definitionMap.set('type', meta.internalType);
|
|
22180
22220
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -22225,7 +22265,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
22225
22265
|
function createInjectorDefinitionMap(meta) {
|
|
22226
22266
|
const definitionMap = new DefinitionMap();
|
|
22227
22267
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
22228
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22268
|
+
definitionMap.set('version', literal('16.0.0-next.3'));
|
|
22229
22269
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22230
22270
|
definitionMap.set('type', meta.internalType);
|
|
22231
22271
|
definitionMap.set('providers', meta.providers);
|
|
@@ -22255,7 +22295,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
|
|
|
22255
22295
|
function createNgModuleDefinitionMap(meta) {
|
|
22256
22296
|
const definitionMap = new DefinitionMap();
|
|
22257
22297
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
22258
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22298
|
+
definitionMap.set('version', literal('16.0.0-next.3'));
|
|
22259
22299
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22260
22300
|
definitionMap.set('type', meta.internalType);
|
|
22261
22301
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -22306,7 +22346,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
22306
22346
|
function createPipeDefinitionMap(meta) {
|
|
22307
22347
|
const definitionMap = new DefinitionMap();
|
|
22308
22348
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
22309
|
-
definitionMap.set('version', literal('16.0.0-next.
|
|
22349
|
+
definitionMap.set('version', literal('16.0.0-next.3'));
|
|
22310
22350
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22311
22351
|
// e.g. `type: MyPipe`
|
|
22312
22352
|
definitionMap.set('type', meta.internalType);
|