@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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.2.0-next.1
2
+ * @license Angular v15.0.0-next.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2926,6 +2926,7 @@ Identifiers.InheritDefinitionFeature = { name: 'ɵɵInheritDefinitionFeature', m
2926
2926
  Identifiers.CopyDefinitionFeature = { name: 'ɵɵCopyDefinitionFeature', moduleName: CORE };
2927
2927
  Identifiers.StandaloneFeature = { name: 'ɵɵStandaloneFeature', moduleName: CORE };
2928
2928
  Identifiers.ProvidersFeature = { name: 'ɵɵProvidersFeature', moduleName: CORE };
2929
+ Identifiers.HostDirectivesFeature = { name: 'ɵɵHostDirectivesFeature', moduleName: CORE };
2929
2930
  Identifiers.listener = { name: 'ɵɵlistener', moduleName: CORE };
2930
2931
  Identifiers.getInheritedFactory = {
2931
2932
  name: 'ɵɵgetInheritedFactory',
@@ -9948,10 +9949,18 @@ class _ParseAST {
9948
9949
  } // read all semicolons
9949
9950
  }
9950
9951
  else if (this.index < this.tokens.length) {
9952
+ const errorIndex = this.index;
9951
9953
  this.error(`Unexpected token '${this.next}'`);
9954
+ // The `error` call above will skip ahead to the next recovery point in an attempt to
9955
+ // recover part of the expression, but that might be the token we started from which will
9956
+ // lead to an infinite loop. If that's the case, break the loop assuming that we can't
9957
+ // parse further.
9958
+ if (this.index === errorIndex) {
9959
+ break;
9960
+ }
9952
9961
  }
9953
9962
  }
9954
- if (exprs.length == 0) {
9963
+ if (exprs.length === 0) {
9955
9964
  // We have no expressions so create an empty expression that spans the entire input length
9956
9965
  const artificialStart = this.offset;
9957
9966
  const artificialEnd = this.offset + this.input.length;
@@ -18797,6 +18806,7 @@ function baseDirectiveFields(meta, constantPool, bindingParser) {
18797
18806
  * Add features to the definition map.
18798
18807
  */
18799
18808
  function addFeatures(definitionMap, meta) {
18809
+ var _a;
18800
18810
  // e.g. `features: [NgOnChangesFeature]`
18801
18811
  const features = [];
18802
18812
  const providers = meta.providers;
@@ -18821,6 +18831,9 @@ function addFeatures(definitionMap, meta) {
18821
18831
  if (meta.hasOwnProperty('template') && meta.isStandalone) {
18822
18832
  features.push(importExpr(Identifiers.StandaloneFeature));
18823
18833
  }
18834
+ if ((_a = meta.hostDirectives) === null || _a === void 0 ? void 0 : _a.length) {
18835
+ features.push(importExpr(Identifiers.HostDirectivesFeature).callFn([createHostDirectivesFeatureArg(meta.hostDirectives)]));
18836
+ }
18824
18837
  if (features.length) {
18825
18838
  definitionMap.set('features', literalArr(features));
18826
18839
  }
@@ -18933,6 +18946,7 @@ function createComponentType(meta) {
18933
18946
  const typeParams = createBaseDirectiveTypeParams(meta);
18934
18947
  typeParams.push(stringArrayAsType(meta.template.ngContentSelectors));
18935
18948
  typeParams.push(expressionType(literal(meta.isStandalone)));
18949
+ typeParams.push(createHostDirectivesType(meta));
18936
18950
  return expressionType(importExpr(Identifiers.ComponentDeclaration, typeParams));
18937
18951
  }
18938
18952
  /**
@@ -19008,7 +19022,7 @@ function createContentQueriesFunction(queries, constantPool, name) {
19008
19022
  function stringAsType(str) {
19009
19023
  return expressionType(literal(str));
19010
19024
  }
19011
- function stringMapAsType(map) {
19025
+ function stringMapAsLiteralExpression(map) {
19012
19026
  const mapValues = Object.keys(map).map(key => {
19013
19027
  const value = Array.isArray(map[key]) ? map[key][0] : map[key];
19014
19028
  return {
@@ -19017,7 +19031,7 @@ function stringMapAsType(map) {
19017
19031
  quoted: true,
19018
19032
  };
19019
19033
  });
19020
- return expressionType(literalMap(mapValues));
19034
+ return literalMap(mapValues);
19021
19035
  }
19022
19036
  function stringArrayAsType(arr) {
19023
19037
  return arr.length > 0 ? expressionType(literalArr(arr.map(value => literal(value)))) :
@@ -19031,8 +19045,8 @@ function createBaseDirectiveTypeParams(meta) {
19031
19045
  typeWithParameters(meta.type.type, meta.typeArgumentCount),
19032
19046
  selectorForType !== null ? stringAsType(selectorForType) : NONE_TYPE,
19033
19047
  meta.exportAs !== null ? stringArrayAsType(meta.exportAs) : NONE_TYPE,
19034
- stringMapAsType(meta.inputs),
19035
- stringMapAsType(meta.outputs),
19048
+ expressionType(stringMapAsLiteralExpression(meta.inputs)),
19049
+ expressionType(stringMapAsLiteralExpression(meta.outputs)),
19036
19050
  stringArrayAsType(meta.queries.map(q => q.propertyName)),
19037
19051
  ];
19038
19052
  }
@@ -19046,6 +19060,7 @@ function createDirectiveType(meta) {
19046
19060
  // so that future fields align.
19047
19061
  typeParams.push(NONE_TYPE);
19048
19062
  typeParams.push(expressionType(literal(meta.isStandalone)));
19063
+ typeParams.push(createHostDirectivesType(meta));
19049
19064
  return expressionType(importExpr(Identifiers.DirectiveDeclaration, typeParams));
19050
19065
  }
19051
19066
  // Define and update any view queries
@@ -19349,6 +19364,69 @@ function compileStyles(styles, selector, hostSelector) {
19349
19364
  return shadowCss.shimCssText(style, selector, hostSelector);
19350
19365
  });
19351
19366
  }
19367
+ function createHostDirectivesType(meta) {
19368
+ var _a;
19369
+ if (!((_a = meta.hostDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
19370
+ return NONE_TYPE;
19371
+ }
19372
+ return expressionType(literalArr(meta.hostDirectives.map(hostMeta => literalMap([
19373
+ { key: 'directive', value: typeofExpr(hostMeta.directive.type), quoted: false },
19374
+ { key: 'inputs', value: stringMapAsLiteralExpression(hostMeta.inputs || {}), quoted: false },
19375
+ { key: 'outputs', value: stringMapAsLiteralExpression(hostMeta.outputs || {}), quoted: false },
19376
+ ]))));
19377
+ }
19378
+ function createHostDirectivesFeatureArg(hostDirectives) {
19379
+ const expressions = [];
19380
+ let hasForwardRef = false;
19381
+ for (const current of hostDirectives) {
19382
+ // Use a shorthand if there are no inputs or outputs.
19383
+ if (!current.inputs && !current.outputs) {
19384
+ expressions.push(current.directive.type);
19385
+ }
19386
+ else {
19387
+ const keys = [{ key: 'directive', value: current.directive.type, quoted: false }];
19388
+ if (current.inputs) {
19389
+ const inputsLiteral = createHostDirectivesMappingArray(current.inputs);
19390
+ if (inputsLiteral) {
19391
+ keys.push({ key: 'inputs', value: inputsLiteral, quoted: false });
19392
+ }
19393
+ }
19394
+ if (current.outputs) {
19395
+ const outputsLiteral = createHostDirectivesMappingArray(current.outputs);
19396
+ if (outputsLiteral) {
19397
+ keys.push({ key: 'outputs', value: outputsLiteral, quoted: false });
19398
+ }
19399
+ }
19400
+ expressions.push(literalMap(keys));
19401
+ }
19402
+ if (current.isForwardReference) {
19403
+ hasForwardRef = true;
19404
+ }
19405
+ }
19406
+ // If there's a forward reference, we generate a `function() { return [HostDir] }`,
19407
+ // otherwise we can save some bytes by using a plain array, e.g. `[HostDir]`.
19408
+ return hasForwardRef ?
19409
+ new FunctionExpr([], [new ReturnStatement(literalArr(expressions))]) :
19410
+ literalArr(expressions);
19411
+ }
19412
+ /**
19413
+ * Converts an input/output mapping object literal into an array where the even keys are the
19414
+ * public name of the binding and the odd ones are the name it was aliased to. E.g.
19415
+ * `{inputOne: 'aliasOne', inputTwo: 'aliasTwo'}` will become
19416
+ * `['inputOne', 'aliasOne', 'inputTwo', 'aliasTwo']`.
19417
+ *
19418
+ * This conversion is necessary, because hosts bind to the public name of the host directive and
19419
+ * keeping the mapping in an object literal will break for apps using property renaming.
19420
+ */
19421
+ function createHostDirectivesMappingArray(mapping) {
19422
+ const elements = [];
19423
+ for (const publicName in mapping) {
19424
+ if (mapping.hasOwnProperty(publicName)) {
19425
+ elements.push(literal(publicName), literal(mapping[publicName]));
19426
+ }
19427
+ }
19428
+ return elements.length > 0 ? literalArr(elements) : null;
19429
+ }
19352
19430
 
19353
19431
  /**
19354
19432
  * @license
@@ -19598,7 +19676,7 @@ function convertDirectiveFacadeToMetadata(facade) {
19598
19676
  });
19599
19677
  }
19600
19678
  }
19601
- 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 });
19679
+ 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, hostDirectives: convertHostDirectivesToMetadata(facade) });
19602
19680
  }
19603
19681
  function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
19604
19682
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -19622,6 +19700,7 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
19622
19700
  typeArgumentCount: 0,
19623
19701
  fullInheritance: false,
19624
19702
  isStandalone: (_j = declaration.isStandalone) !== null && _j !== void 0 ? _j : false,
19703
+ hostDirectives: convertHostDirectivesToMetadata(declaration),
19625
19704
  };
19626
19705
  }
19627
19706
  function convertHostDeclarationToMetadata(host = {}) {
@@ -19636,6 +19715,27 @@ function convertHostDeclarationToMetadata(host = {}) {
19636
19715
  },
19637
19716
  };
19638
19717
  }
19718
+ function convertHostDirectivesToMetadata(metadata) {
19719
+ var _a;
19720
+ if ((_a = metadata.hostDirectives) === null || _a === void 0 ? void 0 : _a.length) {
19721
+ return metadata.hostDirectives.map(hostDirective => {
19722
+ return typeof hostDirective === 'function' ?
19723
+ {
19724
+ directive: wrapReference(hostDirective),
19725
+ inputs: null,
19726
+ outputs: null,
19727
+ isForwardReference: false
19728
+ } :
19729
+ {
19730
+ directive: wrapReference(hostDirective.directive),
19731
+ isForwardReference: false,
19732
+ inputs: hostDirective.inputs ? parseInputOutputs(hostDirective.inputs) : null,
19733
+ outputs: hostDirective.outputs ? parseInputOutputs(hostDirective.outputs) : null,
19734
+ };
19735
+ });
19736
+ }
19737
+ return null;
19738
+ }
19639
19739
  function convertOpaqueValuesToExpressions(obj) {
19640
19740
  const result = {};
19641
19741
  for (const key of Object.keys(obj)) {
@@ -19854,7 +19954,7 @@ function publishFacade(global) {
19854
19954
  * Use of this source code is governed by an MIT-style license that can be
19855
19955
  * found in the LICENSE file at https://angular.io/license
19856
19956
  */
19857
- const VERSION = new Version('14.2.0-next.1');
19957
+ const VERSION = new Version('15.0.0-next.0');
19858
19958
 
19859
19959
  /**
19860
19960
  * @license
@@ -21548,7 +21648,7 @@ class DirectiveBinder {
21548
21648
  const cssSelector = createCssSelector(elementName, getAttrsForDirectiveMatching(node));
21549
21649
  // Next, use the `SelectorMatcher` to get the list of directives on the node.
21550
21650
  const directives = [];
21551
- this.matcher.match(cssSelector, (_, directive) => directives.push(directive));
21651
+ this.matcher.match(cssSelector, (_selector, results) => directives.push(...results));
21552
21652
  if (directives.length > 0) {
21553
21653
  this.directives.set(node, directives);
21554
21654
  }
@@ -21881,7 +21981,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
21881
21981
  function compileDeclareClassMetadata(metadata) {
21882
21982
  const definitionMap = new DefinitionMap();
21883
21983
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
21884
- definitionMap.set('version', literal('14.2.0-next.1'));
21984
+ definitionMap.set('version', literal('15.0.0-next.0'));
21885
21985
  definitionMap.set('ngImport', importExpr(Identifiers.core));
21886
21986
  definitionMap.set('type', metadata.type);
21887
21987
  definitionMap.set('decorators', metadata.decorators);
@@ -21996,9 +22096,10 @@ function compileDeclareDirectiveFromMetadata(meta) {
21996
22096
  * this logic for components, as they extend the directive metadata.
21997
22097
  */
21998
22098
  function createDirectiveDefinitionMap(meta) {
22099
+ var _a;
21999
22100
  const definitionMap = new DefinitionMap();
22000
22101
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
22001
- definitionMap.set('version', literal('14.2.0-next.1'));
22102
+ definitionMap.set('version', literal('15.0.0-next.0'));
22002
22103
  // e.g. `type: MyDirective`
22003
22104
  definitionMap.set('type', meta.internalType);
22004
22105
  if (meta.isStandalone) {
@@ -22027,6 +22128,9 @@ function createDirectiveDefinitionMap(meta) {
22027
22128
  if (meta.lifecycle.usesOnChanges) {
22028
22129
  definitionMap.set('usesOnChanges', literal(true));
22029
22130
  }
22131
+ if ((_a = meta.hostDirectives) === null || _a === void 0 ? void 0 : _a.length) {
22132
+ definitionMap.set('hostDirectives', createHostDirectives(meta.hostDirectives));
22133
+ }
22030
22134
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22031
22135
  return definitionMap;
22032
22136
  }
@@ -22081,6 +22185,28 @@ function compileHostMetadata(meta) {
22081
22185
  return null;
22082
22186
  }
22083
22187
  }
22188
+ function createHostDirectives(hostDirectives) {
22189
+ const expressions = hostDirectives.map(current => {
22190
+ const keys = [{
22191
+ key: 'directive',
22192
+ value: current.isForwardReference ? generateForwardRef(current.directive.type) :
22193
+ current.directive.type,
22194
+ quoted: false
22195
+ }];
22196
+ const inputsLiteral = current.inputs ? createHostDirectivesMappingArray(current.inputs) : null;
22197
+ const outputsLiteral = current.outputs ? createHostDirectivesMappingArray(current.outputs) : null;
22198
+ if (inputsLiteral) {
22199
+ keys.push({ key: 'inputs', value: inputsLiteral, quoted: false });
22200
+ }
22201
+ if (outputsLiteral) {
22202
+ keys.push({ key: 'outputs', value: outputsLiteral, quoted: false });
22203
+ }
22204
+ return literalMap(keys);
22205
+ });
22206
+ // If there's a forward reference, we generate a `function() { return [{directive: HostDir}] }`,
22207
+ // otherwise we can save some bytes by using a plain array, e.g. `[{directive: HostDir}]`.
22208
+ return literalArr(expressions);
22209
+ }
22084
22210
 
22085
22211
  /**
22086
22212
  * @license
@@ -22212,7 +22338,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
22212
22338
  function compileDeclareFactoryFunction(meta) {
22213
22339
  const definitionMap = new DefinitionMap();
22214
22340
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
22215
- definitionMap.set('version', literal('14.2.0-next.1'));
22341
+ definitionMap.set('version', literal('15.0.0-next.0'));
22216
22342
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22217
22343
  definitionMap.set('type', meta.internalType);
22218
22344
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -22254,7 +22380,7 @@ function compileDeclareInjectableFromMetadata(meta) {
22254
22380
  function createInjectableDefinitionMap(meta) {
22255
22381
  const definitionMap = new DefinitionMap();
22256
22382
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
22257
- definitionMap.set('version', literal('14.2.0-next.1'));
22383
+ definitionMap.set('version', literal('15.0.0-next.0'));
22258
22384
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22259
22385
  definitionMap.set('type', meta.internalType);
22260
22386
  // Only generate providedIn property if it has a non-null value
@@ -22312,7 +22438,7 @@ function compileDeclareInjectorFromMetadata(meta) {
22312
22438
  function createInjectorDefinitionMap(meta) {
22313
22439
  const definitionMap = new DefinitionMap();
22314
22440
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
22315
- definitionMap.set('version', literal('14.2.0-next.1'));
22441
+ definitionMap.set('version', literal('15.0.0-next.0'));
22316
22442
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22317
22443
  definitionMap.set('type', meta.internalType);
22318
22444
  definitionMap.set('providers', meta.providers);
@@ -22349,7 +22475,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
22349
22475
  function createNgModuleDefinitionMap(meta) {
22350
22476
  const definitionMap = new DefinitionMap();
22351
22477
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
22352
- definitionMap.set('version', literal('14.2.0-next.1'));
22478
+ definitionMap.set('version', literal('15.0.0-next.0'));
22353
22479
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22354
22480
  definitionMap.set('type', meta.internalType);
22355
22481
  // We only generate the keys in the metadata if the arrays contain values.
@@ -22407,7 +22533,7 @@ function compileDeclarePipeFromMetadata(meta) {
22407
22533
  function createPipeDefinitionMap(meta) {
22408
22534
  const definitionMap = new DefinitionMap();
22409
22535
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
22410
- definitionMap.set('version', literal('14.2.0-next.1'));
22536
+ definitionMap.set('version', literal('15.0.0-next.0'));
22411
22537
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22412
22538
  // e.g. `type: MyPipe`
22413
22539
  definitionMap.set('type', meta.internalType);