@angular/core 15.2.2 → 15.2.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v15.2.2
2
+ * @license Angular v15.2.4
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2194,7 +2194,7 @@ let componentDefCount = 0;
2194
2194
  *
2195
2195
  * # Example
2196
2196
  * ```
2197
- * class MyDirective {
2197
+ * class MyComponent {
2198
2198
  * // Generated by Angular Template Compiler
2199
2199
  * // [Symbol] syntax will not be supported by TypeScript until v2.7
2200
2200
  * static ɵcmp = defineComponent({
@@ -2209,61 +2209,31 @@ function ɵɵdefineComponent(componentDefinition) {
2209
2209
  // Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent.
2210
2210
  // See the `initNgDevMode` docstring for more information.
2211
2211
  (typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
2212
- const type = componentDefinition.type;
2213
- const standalone = componentDefinition.standalone === true;
2214
- const declaredInputs = {};
2212
+ const baseDef = getNgDirectiveDef(componentDefinition);
2215
2213
  const def = {
2216
- type: type,
2217
- providersResolver: null,
2214
+ ...baseDef,
2218
2215
  decls: componentDefinition.decls,
2219
2216
  vars: componentDefinition.vars,
2220
- factory: null,
2221
- template: componentDefinition.template || null,
2217
+ template: componentDefinition.template,
2222
2218
  consts: componentDefinition.consts || null,
2223
2219
  ngContentSelectors: componentDefinition.ngContentSelectors,
2224
- hostBindings: componentDefinition.hostBindings || null,
2225
- hostVars: componentDefinition.hostVars || 0,
2226
- hostAttrs: componentDefinition.hostAttrs || null,
2227
- contentQueries: componentDefinition.contentQueries || null,
2228
- declaredInputs: declaredInputs,
2229
- inputs: null,
2230
- outputs: null,
2231
- exportAs: componentDefinition.exportAs || null,
2232
2220
  onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
2233
2221
  directiveDefs: null,
2234
2222
  pipeDefs: null,
2235
- standalone,
2236
- dependencies: standalone && componentDefinition.dependencies || null,
2223
+ dependencies: baseDef.standalone && componentDefinition.dependencies || null,
2237
2224
  getStandaloneInjector: null,
2238
- selectors: componentDefinition.selectors || EMPTY_ARRAY,
2239
- viewQuery: componentDefinition.viewQuery || null,
2240
- features: componentDefinition.features || null,
2241
2225
  data: componentDefinition.data || {},
2242
2226
  encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated,
2243
2227
  id: `c${componentDefCount++}`,
2244
2228
  styles: componentDefinition.styles || EMPTY_ARRAY,
2245
2229
  _: null,
2246
- setInput: null,
2247
2230
  schemas: componentDefinition.schemas || null,
2248
2231
  tView: null,
2249
- findHostDirectiveDefs: null,
2250
- hostDirectives: null,
2251
2232
  };
2233
+ initFeatures(def);
2252
2234
  const dependencies = componentDefinition.dependencies;
2253
- const feature = componentDefinition.features;
2254
- def.inputs = invertObject(componentDefinition.inputs, declaredInputs),
2255
- def.outputs = invertObject(componentDefinition.outputs),
2256
- feature && feature.forEach((fn) => fn(def));
2257
- def.directiveDefs = dependencies ?
2258
- (() => (typeof dependencies === 'function' ? dependencies() : dependencies)
2259
- .map(extractDirectiveDef)
2260
- .filter(nonNull)) :
2261
- null;
2262
- def.pipeDefs = dependencies ?
2263
- (() => (typeof dependencies === 'function' ? dependencies() : dependencies)
2264
- .map(getPipeDef$1)
2265
- .filter(nonNull)) :
2266
- null;
2235
+ def.directiveDefs = extractDefListOrFactory(dependencies, /* pipeDef */ false);
2236
+ def.pipeDefs = extractDefListOrFactory(dependencies, /* pipeDef */ true);
2267
2237
  return def;
2268
2238
  });
2269
2239
  }
@@ -2278,8 +2248,8 @@ function ɵɵdefineComponent(componentDefinition) {
2278
2248
  */
2279
2249
  function ɵɵsetComponentScope(type, directives, pipes) {
2280
2250
  const def = type.ɵcmp;
2281
- def.directiveDefs = () => (typeof directives === 'function' ? directives() : directives).map(extractDirectiveDef);
2282
- def.pipeDefs = () => (typeof pipes === 'function' ? pipes() : pipes).map(getPipeDef$1);
2251
+ def.directiveDefs = extractDefListOrFactory(directives, /* pipeDef */ false);
2252
+ def.pipeDefs = extractDefListOrFactory(pipes, /* pipeDef */ true);
2283
2253
  }
2284
2254
  function extractDirectiveDef(type) {
2285
2255
  return getComponentDef$1(type) || getDirectiveDef(type);
@@ -2414,7 +2384,13 @@ function invertObject(obj, secondary) {
2414
2384
  *
2415
2385
  * @codeGenApi
2416
2386
  */
2417
- const ɵɵdefineDirective = ɵɵdefineComponent;
2387
+ function ɵɵdefineDirective(directiveDefinition) {
2388
+ return noSideEffects(() => {
2389
+ const def = getNgDirectiveDef(directiveDefinition);
2390
+ initFeatures(def);
2391
+ return def;
2392
+ });
2393
+ }
2418
2394
  /**
2419
2395
  * Create a pipe definition object.
2420
2396
  *
@@ -2474,6 +2450,41 @@ function getNgModuleDef(type, throwNotFound) {
2474
2450
  }
2475
2451
  return ngModuleDef;
2476
2452
  }
2453
+ function getNgDirectiveDef(directiveDefinition) {
2454
+ const declaredInputs = {};
2455
+ return {
2456
+ type: directiveDefinition.type,
2457
+ providersResolver: null,
2458
+ factory: null,
2459
+ hostBindings: directiveDefinition.hostBindings || null,
2460
+ hostVars: directiveDefinition.hostVars || 0,
2461
+ hostAttrs: directiveDefinition.hostAttrs || null,
2462
+ contentQueries: directiveDefinition.contentQueries || null,
2463
+ declaredInputs,
2464
+ exportAs: directiveDefinition.exportAs || null,
2465
+ standalone: directiveDefinition.standalone === true,
2466
+ selectors: directiveDefinition.selectors || EMPTY_ARRAY,
2467
+ viewQuery: directiveDefinition.viewQuery || null,
2468
+ features: directiveDefinition.features || null,
2469
+ setInput: null,
2470
+ findHostDirectiveDefs: null,
2471
+ hostDirectives: null,
2472
+ inputs: invertObject(directiveDefinition.inputs, declaredInputs),
2473
+ outputs: invertObject(directiveDefinition.outputs),
2474
+ };
2475
+ }
2476
+ function initFeatures(definition) {
2477
+ definition.features?.forEach((fn) => fn(definition));
2478
+ }
2479
+ function extractDefListOrFactory(dependencies, pipeDef) {
2480
+ if (!dependencies) {
2481
+ return null;
2482
+ }
2483
+ const defExtractor = pipeDef ? getPipeDef$1 : extractDirectiveDef;
2484
+ return () => (typeof dependencies === 'function' ? dependencies() : dependencies)
2485
+ .map(dep => defExtractor(dep))
2486
+ .filter(nonNull);
2487
+ }
2477
2488
 
2478
2489
  // Below are constants for LView indices to help us look up LView members
2479
2490
  // without having to remember the specific indices.
@@ -2575,7 +2586,7 @@ function isDirectiveHost(tNode) {
2575
2586
  return (tNode.flags & 1 /* TNodeFlags.isDirectiveHost */) === 1 /* TNodeFlags.isDirectiveHost */;
2576
2587
  }
2577
2588
  function isComponentDef(def) {
2578
- return def.template !== null;
2589
+ return !!def.template;
2579
2590
  }
2580
2591
  function isRootView(target) {
2581
2592
  return (target[FLAGS] & 256 /* LViewFlags.IsRoot */) !== 0;
@@ -8694,7 +8705,7 @@ class Version {
8694
8705
  /**
8695
8706
  * @publicApi
8696
8707
  */
8697
- const VERSION = new Version('15.2.2');
8708
+ const VERSION = new Version('15.2.4');
8698
8709
 
8699
8710
  // This default value is when checking the hierarchy for a token.
8700
8711
  //
@@ -8928,12 +8939,19 @@ function isCssClassMatching(attrs, cssClassToMatch, isProjectionMode) {
8928
8939
  ngDevMode &&
8929
8940
  assertEqual(cssClassToMatch, cssClassToMatch.toLowerCase(), 'Class name expected to be lowercase.');
8930
8941
  let i = 0;
8942
+ // Indicates whether we are processing value from the implicit
8943
+ // attribute section (i.e. before the first marker in the array).
8944
+ let isImplicitAttrsSection = true;
8931
8945
  while (i < attrs.length) {
8932
8946
  let item = attrs[i++];
8933
- if (isProjectionMode && item === 'class') {
8934
- item = attrs[i];
8935
- if (classIndexOf(item.toLowerCase(), cssClassToMatch, 0) !== -1) {
8936
- return true;
8947
+ if (typeof item === 'string' && isImplicitAttrsSection) {
8948
+ const value = attrs[i++];
8949
+ if (isProjectionMode && item === 'class') {
8950
+ // We found a `class` attribute in the implicit attribute section,
8951
+ // check if it matches the value of the `cssClassToMatch` argument.
8952
+ if (classIndexOf(value.toLowerCase(), cssClassToMatch, 0) !== -1) {
8953
+ return true;
8954
+ }
8937
8955
  }
8938
8956
  }
8939
8957
  else if (item === 1 /* AttributeMarker.Classes */) {
@@ -8945,6 +8963,11 @@ function isCssClassMatching(attrs, cssClassToMatch, isProjectionMode) {
8945
8963
  }
8946
8964
  return false;
8947
8965
  }
8966
+ else if (typeof item === 'number') {
8967
+ // We've came across a first marker, which indicates
8968
+ // that the implicit attribute section is over.
8969
+ isImplicitAttrsSection = false;
8970
+ }
8948
8971
  }
8949
8972
  return false;
8950
8973
  }
@@ -20571,7 +20594,8 @@ function sortListeners(a, b) {
20571
20594
  * See call site for more info.
20572
20595
  */
20573
20596
  function isDirectiveDefHack(obj) {
20574
- return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
20597
+ return obj.type !== undefined && obj.declaredInputs !== undefined &&
20598
+ obj.findHostDirectiveDefs !== undefined;
20575
20599
  }
20576
20600
  /**
20577
20601
  * Retrieve the component `LView` from component/element.
@@ -23559,10 +23583,11 @@ class TestBedCompiler {
23559
23583
  }
23560
23584
  }
23561
23585
  queueTypesFromModulesArray(arr) {
23562
- // Because we may encounter the same NgModule while processing the imports and exports of an
23563
- // NgModule tree, we cache them in this set so we can skip ones that have already been seen
23564
- // encountered. In some test setups, this caching resulted in 10X runtime improvement.
23565
- const processedNgModuleDefs = new Set();
23586
+ // Because we may encounter the same NgModule or a standalone Component while processing
23587
+ // the dependencies of an NgModule or a standalone Component, we cache them in this set so we
23588
+ // can skip ones that have already been seen encountered. In some test setups, this caching
23589
+ // resulted in 10X runtime improvement.
23590
+ const processedDefs = new Set();
23566
23591
  const queueTypesFromModulesArrayRecur = (arr) => {
23567
23592
  for (const value of arr) {
23568
23593
  if (Array.isArray(value)) {
@@ -23570,10 +23595,10 @@ class TestBedCompiler {
23570
23595
  }
23571
23596
  else if (hasNgModuleDef(value)) {
23572
23597
  const def = value.ɵmod;
23573
- if (processedNgModuleDefs.has(def)) {
23598
+ if (processedDefs.has(def)) {
23574
23599
  continue;
23575
23600
  }
23576
- processedNgModuleDefs.add(def);
23601
+ processedDefs.add(def);
23577
23602
  // Look through declarations, imports, and exports, and queue
23578
23603
  // everything found there.
23579
23604
  this.queueTypeArray(maybeUnwrapFn(def.declarations), value);
@@ -23586,6 +23611,10 @@ class TestBedCompiler {
23586
23611
  else if (isStandaloneComponent(value)) {
23587
23612
  this.queueType(value, null);
23588
23613
  const def = getComponentDef(value);
23614
+ if (processedDefs.has(def)) {
23615
+ continue;
23616
+ }
23617
+ processedDefs.add(def);
23589
23618
  const dependencies = maybeUnwrapFn(def.dependencies ?? []);
23590
23619
  dependencies.forEach((dependency) => {
23591
23620
  // Note: in AOT, the `dependencies` might also contain regular