@angular/core 15.2.1 → 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.
Files changed (33) hide show
  1. package/esm2020/src/application_ref.mjs +14 -3
  2. package/esm2020/src/application_tokens.mjs +1 -12
  3. package/esm2020/src/change_detection/change_detection.mjs +2 -2
  4. package/esm2020/src/change_detection/constants.mjs +1 -49
  5. package/esm2020/src/core.mjs +3 -3
  6. package/esm2020/src/core_private_export.mjs +1 -5
  7. package/esm2020/src/linker/template_ref.mjs +3 -3
  8. package/esm2020/src/render3/definition.mjs +53 -42
  9. package/esm2020/src/render3/i18n/i18n_util.mjs +3 -3
  10. package/esm2020/src/render3/instructions/shared.mjs +2 -2
  11. package/esm2020/src/render3/instructions/template.mjs +2 -2
  12. package/esm2020/src/render3/interfaces/node.mjs +1 -1
  13. package/esm2020/src/render3/interfaces/type_checks.mjs +2 -2
  14. package/esm2020/src/render3/jit/directive.mjs +1 -2
  15. package/esm2020/src/render3/util/discovery_utils.mjs +3 -2
  16. package/esm2020/src/version.mjs +1 -1
  17. package/esm2020/testing/src/logger.mjs +3 -3
  18. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  19. package/fesm2015/core.mjs +76 -133
  20. package/fesm2015/core.mjs.map +1 -1
  21. package/fesm2015/testing.mjs +62 -116
  22. package/fesm2015/testing.mjs.map +1 -1
  23. package/fesm2020/core.mjs +76 -116
  24. package/fesm2020/core.mjs.map +1 -1
  25. package/fesm2020/testing.mjs +63 -99
  26. package/fesm2020/testing.mjs.map +1 -1
  27. package/index.d.ts +248 -422
  28. package/package.json +1 -1
  29. package/schematics/migrations/relative-link-resolution/bundle.js +7 -7
  30. package/schematics/migrations/router-link-with-href/bundle.js +10 -10
  31. package/schematics/ng-generate/standalone-migration/bundle.js +699 -674
  32. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  33. package/testing/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v15.2.1
2
+ * @license Angular v15.2.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2114,54 +2114,6 @@ var ChangeDetectionStrategy;
2114
2114
  */
2115
2115
  ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 1] = "Default";
2116
2116
  })(ChangeDetectionStrategy || (ChangeDetectionStrategy = {}));
2117
- /**
2118
- * Defines the possible states of the default change detector.
2119
- * @see `ChangeDetectorRef`
2120
- */
2121
- var ChangeDetectorStatus;
2122
- (function (ChangeDetectorStatus) {
2123
- /**
2124
- * A state in which, after calling `detectChanges()`, the change detector
2125
- * state becomes `Checked`, and must be explicitly invoked or reactivated.
2126
- */
2127
- ChangeDetectorStatus[ChangeDetectorStatus["CheckOnce"] = 0] = "CheckOnce";
2128
- /**
2129
- * A state in which change detection is skipped until the change detector mode
2130
- * becomes `CheckOnce`.
2131
- */
2132
- ChangeDetectorStatus[ChangeDetectorStatus["Checked"] = 1] = "Checked";
2133
- /**
2134
- * A state in which change detection continues automatically until explicitly
2135
- * deactivated.
2136
- */
2137
- ChangeDetectorStatus[ChangeDetectorStatus["CheckAlways"] = 2] = "CheckAlways";
2138
- /**
2139
- * A state in which a change detector sub tree is not a part of the main tree and
2140
- * should be skipped.
2141
- */
2142
- ChangeDetectorStatus[ChangeDetectorStatus["Detached"] = 3] = "Detached";
2143
- /**
2144
- * Indicates that the change detector encountered an error checking a binding
2145
- * or calling a directive lifecycle method and is now in an inconsistent state. Change
2146
- * detectors in this state do not detect changes.
2147
- */
2148
- ChangeDetectorStatus[ChangeDetectorStatus["Errored"] = 4] = "Errored";
2149
- /**
2150
- * Indicates that the change detector has been destroyed.
2151
- */
2152
- ChangeDetectorStatus[ChangeDetectorStatus["Destroyed"] = 5] = "Destroyed";
2153
- })(ChangeDetectorStatus || (ChangeDetectorStatus = {}));
2154
- /**
2155
- * Reports whether a given strategy is currently the default for change detection.
2156
- * @param changeDetectionStrategy The strategy to check.
2157
- * @returns True if the given strategy is the current default, false otherwise.
2158
- * @see `ChangeDetectorStatus`
2159
- * @see `ChangeDetectorRef`
2160
- */
2161
- function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
2162
- return changeDetectionStrategy == null ||
2163
- changeDetectionStrategy === ChangeDetectionStrategy.Default;
2164
- }
2165
2117
 
2166
2118
  /**
2167
2119
  * Defines the CSS styles encapsulation policies for the {@link Component} decorator's
@@ -2242,7 +2194,7 @@ let componentDefCount = 0;
2242
2194
  *
2243
2195
  * # Example
2244
2196
  * ```
2245
- * class MyDirective {
2197
+ * class MyComponent {
2246
2198
  * // Generated by Angular Template Compiler
2247
2199
  * // [Symbol] syntax will not be supported by TypeScript until v2.7
2248
2200
  * static ɵcmp = defineComponent({
@@ -2257,61 +2209,31 @@ function ɵɵdefineComponent(componentDefinition) {
2257
2209
  // Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent.
2258
2210
  // See the `initNgDevMode` docstring for more information.
2259
2211
  (typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
2260
- const type = componentDefinition.type;
2261
- const standalone = componentDefinition.standalone === true;
2262
- const declaredInputs = {};
2212
+ const baseDef = getNgDirectiveDef(componentDefinition);
2263
2213
  const def = {
2264
- type: type,
2265
- providersResolver: null,
2214
+ ...baseDef,
2266
2215
  decls: componentDefinition.decls,
2267
2216
  vars: componentDefinition.vars,
2268
- factory: null,
2269
- template: componentDefinition.template || null,
2217
+ template: componentDefinition.template,
2270
2218
  consts: componentDefinition.consts || null,
2271
2219
  ngContentSelectors: componentDefinition.ngContentSelectors,
2272
- hostBindings: componentDefinition.hostBindings || null,
2273
- hostVars: componentDefinition.hostVars || 0,
2274
- hostAttrs: componentDefinition.hostAttrs || null,
2275
- contentQueries: componentDefinition.contentQueries || null,
2276
- declaredInputs: declaredInputs,
2277
- inputs: null,
2278
- outputs: null,
2279
- exportAs: componentDefinition.exportAs || null,
2280
2220
  onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
2281
2221
  directiveDefs: null,
2282
2222
  pipeDefs: null,
2283
- standalone,
2284
- dependencies: standalone && componentDefinition.dependencies || null,
2223
+ dependencies: baseDef.standalone && componentDefinition.dependencies || null,
2285
2224
  getStandaloneInjector: null,
2286
- selectors: componentDefinition.selectors || EMPTY_ARRAY,
2287
- viewQuery: componentDefinition.viewQuery || null,
2288
- features: componentDefinition.features || null,
2289
2225
  data: componentDefinition.data || {},
2290
2226
  encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated,
2291
2227
  id: `c${componentDefCount++}`,
2292
2228
  styles: componentDefinition.styles || EMPTY_ARRAY,
2293
2229
  _: null,
2294
- setInput: null,
2295
2230
  schemas: componentDefinition.schemas || null,
2296
2231
  tView: null,
2297
- findHostDirectiveDefs: null,
2298
- hostDirectives: null,
2299
2232
  };
2233
+ initFeatures(def);
2300
2234
  const dependencies = componentDefinition.dependencies;
2301
- const feature = componentDefinition.features;
2302
- def.inputs = invertObject(componentDefinition.inputs, declaredInputs),
2303
- def.outputs = invertObject(componentDefinition.outputs),
2304
- feature && feature.forEach((fn) => fn(def));
2305
- def.directiveDefs = dependencies ?
2306
- (() => (typeof dependencies === 'function' ? dependencies() : dependencies)
2307
- .map(extractDirectiveDef)
2308
- .filter(nonNull)) :
2309
- null;
2310
- def.pipeDefs = dependencies ?
2311
- (() => (typeof dependencies === 'function' ? dependencies() : dependencies)
2312
- .map(getPipeDef$1)
2313
- .filter(nonNull)) :
2314
- null;
2235
+ def.directiveDefs = extractDefListOrFactory(dependencies, /* pipeDef */ false);
2236
+ def.pipeDefs = extractDefListOrFactory(dependencies, /* pipeDef */ true);
2315
2237
  return def;
2316
2238
  });
2317
2239
  }
@@ -2326,8 +2248,8 @@ function ɵɵdefineComponent(componentDefinition) {
2326
2248
  */
2327
2249
  function ɵɵsetComponentScope(type, directives, pipes) {
2328
2250
  const def = type.ɵcmp;
2329
- def.directiveDefs = () => (typeof directives === 'function' ? directives() : directives).map(extractDirectiveDef);
2330
- def.pipeDefs = () => (typeof pipes === 'function' ? pipes() : pipes).map(getPipeDef$1);
2251
+ def.directiveDefs = extractDefListOrFactory(directives, /* pipeDef */ false);
2252
+ def.pipeDefs = extractDefListOrFactory(pipes, /* pipeDef */ true);
2331
2253
  }
2332
2254
  function extractDirectiveDef(type) {
2333
2255
  return getComponentDef$1(type) || getDirectiveDef(type);
@@ -2462,7 +2384,13 @@ function invertObject(obj, secondary) {
2462
2384
  *
2463
2385
  * @codeGenApi
2464
2386
  */
2465
- const ɵɵdefineDirective = ɵɵdefineComponent;
2387
+ function ɵɵdefineDirective(directiveDefinition) {
2388
+ return noSideEffects(() => {
2389
+ const def = getNgDirectiveDef(directiveDefinition);
2390
+ initFeatures(def);
2391
+ return def;
2392
+ });
2393
+ }
2466
2394
  /**
2467
2395
  * Create a pipe definition object.
2468
2396
  *
@@ -2522,6 +2450,41 @@ function getNgModuleDef(type, throwNotFound) {
2522
2450
  }
2523
2451
  return ngModuleDef;
2524
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
+ }
2525
2488
 
2526
2489
  // Below are constants for LView indices to help us look up LView members
2527
2490
  // without having to remember the specific indices.
@@ -2623,7 +2586,7 @@ function isDirectiveHost(tNode) {
2623
2586
  return (tNode.flags & 1 /* TNodeFlags.isDirectiveHost */) === 1 /* TNodeFlags.isDirectiveHost */;
2624
2587
  }
2625
2588
  function isComponentDef(def) {
2626
- return def.template !== null;
2589
+ return !!def.template;
2627
2590
  }
2628
2591
  function isRootView(target) {
2629
2592
  return (target[FLAGS] & 256 /* LViewFlags.IsRoot */) !== 0;
@@ -8742,7 +8705,7 @@ class Version {
8742
8705
  /**
8743
8706
  * @publicApi
8744
8707
  */
8745
- const VERSION = new Version('15.2.1');
8708
+ const VERSION = new Version('15.2.3');
8746
8709
 
8747
8710
  // This default value is when checking the hierarchy for a token.
8748
8711
  //
@@ -10994,7 +10957,7 @@ function createTNode(tView, tParent, type, index, value, attrs) {
10994
10957
  initialInputs: undefined,
10995
10958
  inputs: null,
10996
10959
  outputs: null,
10997
- tViews: null,
10960
+ tView: null,
10998
10961
  next: null,
10999
10962
  prev: null,
11000
10963
  projectionNext: null,
@@ -13774,7 +13737,7 @@ function templateFirstCreatePass(index, tView, lView, templateFn, decls, vars, t
13774
13737
  const tNode = getOrCreateTNode(tView, index, 4 /* TNodeType.Container */, tagName || null, getConstant(tViewConsts, attrsIndex));
13775
13738
  resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex));
13776
13739
  registerPostOrderHooks(tView, tNode);
13777
- const embeddedTView = tNode.tViews = createTView(2 /* TViewType.Embedded */, tNode, templateFn, decls, vars, tView.directiveRegistry, tView.pipeRegistry, null, tView.schemas, tViewConsts);
13740
+ const embeddedTView = tNode.tView = createTView(2 /* TViewType.Embedded */, tNode, templateFn, decls, vars, tView.directiveRegistry, tView.pipeRegistry, null, tView.schemas, tViewConsts);
13778
13741
  if (tView.queries !== null) {
13779
13742
  tView.queries.template(tView, tNode);
13780
13743
  embeddedTView.queries = tView.queries.embeddedTView(tNode);
@@ -18133,7 +18096,7 @@ function getTIcu(tView, index) {
18133
18096
  if (value === null || typeof value === 'string')
18134
18097
  return null;
18135
18098
  if (ngDevMode &&
18136
- !(value.hasOwnProperty('tViews') || value.hasOwnProperty('currentCaseLViewIndex'))) {
18099
+ !(value.hasOwnProperty('tView') || value.hasOwnProperty('currentCaseLViewIndex'))) {
18137
18100
  throwError('We expect to get \'null\'|\'TIcu\'|\'TIcuContainer\', but got: ' + value);
18138
18101
  }
18139
18102
  // Here the `value.hasOwnProperty('currentCaseLViewIndex')` is a polymorphic read as it can be
@@ -18162,7 +18125,7 @@ function getTIcu(tView, index) {
18162
18125
  function setTIcu(tView, index, tIcu) {
18163
18126
  const tNode = tView.data[index];
18164
18127
  ngDevMode &&
18165
- assertEqual(tNode === null || tNode.hasOwnProperty('tViews'), true, 'We expect to get \'null\'|\'TIcuContainer\'');
18128
+ assertEqual(tNode === null || tNode.hasOwnProperty('tView'), true, 'We expect to get \'null\'|\'TIcuContainer\'');
18166
18129
  if (tNode === null) {
18167
18130
  tView.data[index] = tIcu;
18168
18131
  }
@@ -20619,7 +20582,8 @@ function sortListeners(a, b) {
20619
20582
  * See call site for more info.
20620
20583
  */
20621
20584
  function isDirectiveDefHack(obj) {
20622
- return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
20585
+ return obj.type !== undefined && obj.declaredInputs !== undefined &&
20586
+ obj.findHostDirectiveDefs !== undefined;
20623
20587
  }
20624
20588
  /**
20625
20589
  * Retrieve the component `LView` from component/element.
@@ -21457,7 +21421,7 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
21457
21421
  this.elementRef = elementRef;
21458
21422
  }
21459
21423
  createEmbeddedView(context, injector) {
21460
- const embeddedTView = this._declarationTContainer.tViews;
21424
+ const embeddedTView = this._declarationTContainer.tView;
21461
21425
  const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* LViewFlags.CheckAlways */, null, embeddedTView.declTNode, null, null, null, null, injector || null);
21462
21426
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
21463
21427
  ngDevMode && assertLContainer(declarationLContainer);
@@ -21487,7 +21451,7 @@ function injectTemplateRef() {
21487
21451
  */
21488
21452
  function createTemplateRef(hostTNode, hostLView) {
21489
21453
  if (hostTNode.type & 4 /* TNodeType.Container */) {
21490
- ngDevMode && assertDefined(hostTNode.tViews, 'TView must be allocated');
21454
+ ngDevMode && assertDefined(hostTNode.tView, 'TView must be allocated');
21491
21455
  return new R3TemplateRef(hostLView, hostTNode, createElementRef(hostTNode, hostLView));
21492
21456
  }
21493
21457
  return null;