@angular/core 15.2.2 → 15.2.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v15.2.2
2
+ * @license Angular v15.2.3
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.3');
8698
8709
 
8699
8710
  // This default value is when checking the hierarchy for a token.
8700
8711
  //
@@ -20571,7 +20582,8 @@ function sortListeners(a, b) {
20571
20582
  * See call site for more info.
20572
20583
  */
20573
20584
  function isDirectiveDefHack(obj) {
20574
- return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
20585
+ return obj.type !== undefined && obj.declaredInputs !== undefined &&
20586
+ obj.findHostDirectiveDefs !== undefined;
20575
20587
  }
20576
20588
  /**
20577
20589
  * Retrieve the component `LView` from component/element.