@angular/core 16.0.0-next.0 → 16.0.0-next.1

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 (57) hide show
  1. package/esm2020/src/application_init.mjs +3 -2
  2. package/esm2020/src/application_module.mjs +3 -2
  3. package/esm2020/src/application_ref.mjs +5 -3
  4. package/esm2020/src/change_detection/change_detector_ref.mjs +3 -2
  5. package/esm2020/src/change_detection/differs/iterable_differs.mjs +3 -2
  6. package/esm2020/src/change_detection/differs/keyvalue_differs.mjs +3 -2
  7. package/esm2020/src/console.mjs +3 -2
  8. package/esm2020/src/core_private_export.mjs +2 -1
  9. package/esm2020/src/core_render3_private_export.mjs +2 -1
  10. package/esm2020/src/di/injector.mjs +3 -2
  11. package/esm2020/src/di/r3_injector.mjs +5 -1
  12. package/esm2020/src/di/reflective_injector.mjs +3 -2
  13. package/esm2020/src/linker/compiler.mjs +3 -2
  14. package/esm2020/src/linker/component_factory_resolver.mjs +3 -2
  15. package/esm2020/src/linker/destroy_ref.mjs +41 -0
  16. package/esm2020/src/linker/element_ref.mjs +3 -2
  17. package/esm2020/src/linker/query_list.mjs +6 -7
  18. package/esm2020/src/linker/template_ref.mjs +3 -2
  19. package/esm2020/src/linker/view_container_ref.mjs +3 -2
  20. package/esm2020/src/linker.mjs +2 -1
  21. package/esm2020/src/render/api.mjs +3 -2
  22. package/esm2020/src/render3/features/standalone_feature.mjs +1 -1
  23. package/esm2020/src/render3/fields.mjs +10 -1
  24. package/esm2020/src/render3/hooks.mjs +3 -2
  25. package/esm2020/src/render3/instructions/element.mjs +10 -9
  26. package/esm2020/src/render3/instructions/shared.mjs +16 -17
  27. package/esm2020/src/render3/interfaces/definition.mjs +1 -1
  28. package/esm2020/src/render3/interfaces/node.mjs +1 -1
  29. package/esm2020/src/render3/interfaces/view.mjs +3 -2
  30. package/esm2020/src/render3/node_manipulation.mjs +14 -14
  31. package/esm2020/src/render3/util/view_utils.mjs +11 -2
  32. package/esm2020/src/render3/view_ref.mjs +4 -3
  33. package/esm2020/src/sanitization/sanitizer.mjs +3 -2
  34. package/esm2020/src/testability/testability.mjs +5 -3
  35. package/esm2020/src/transfer_state.mjs +148 -0
  36. package/esm2020/src/util/iterable.mjs +6 -7
  37. package/esm2020/src/version.mjs +1 -1
  38. package/esm2020/testing/src/logger.mjs +6 -5
  39. package/esm2020/testing/src/ng_zone_mock.mjs +6 -5
  40. package/esm2020/testing/src/test_bed.mjs +3 -2
  41. package/fesm2015/core.mjs +243 -74
  42. package/fesm2015/core.mjs.map +1 -1
  43. package/fesm2015/testing.mjs +74 -73
  44. package/fesm2015/testing.mjs.map +1 -1
  45. package/fesm2020/core.mjs +241 -74
  46. package/fesm2020/core.mjs.map +1 -1
  47. package/fesm2020/testing.mjs +74 -73
  48. package/fesm2020/testing.mjs.map +1 -1
  49. package/index.d.ts +122 -1
  50. package/package.json +3 -3
  51. package/schematics/migrations/relative-link-resolution/bundle.js +7 -7
  52. package/schematics/migrations/router-link-with-href/bundle.js +10 -10
  53. package/schematics/migrations/router-link-with-href/bundle.js.map +2 -2
  54. package/schematics/ng-generate/standalone-migration/bundle.js +1150 -1155
  55. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  56. package/testing/index.d.ts +1 -1
  57. package/esm2020/src/util/symbol.mjs +0 -30
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.0.0-next.0
2
+ * @license Angular v16.0.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2233,6 +2233,15 @@ const NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty })
2233
2233
  */
2234
2234
  // TODO(misko): This is wrong. The NG_ELEMENT_ID should never be minified.
2235
2235
  const NG_ELEMENT_ID = getClosureSafeProperty({ __NG_ELEMENT_ID__: getClosureSafeProperty });
2236
+ /**
2237
+ * The `NG_ENV_ID` field on a DI token indicates special processing in the `EnvironmentInjector`:
2238
+ * getting such tokens from the `EnvironmentInjector` will bypass the standard DI resolution
2239
+ * strategy and instead will return implementation produced by the `NG_ENV_ID` factory function.
2240
+ *
2241
+ * This particular retrieval of DI tokens is mostly done to eliminate circular dependencies and
2242
+ * improve tree-shaking.
2243
+ */
2244
+ const NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
2236
2245
 
2237
2246
  /** Counter used to generate unique IDs for component definitions. */
2238
2247
  let componentDefCount = 0;
@@ -2549,6 +2558,7 @@ const PREORDER_HOOK_FLAGS = 18;
2549
2558
  const QUERIES = 19;
2550
2559
  const ID = 20;
2551
2560
  const EMBEDDED_VIEW_INJECTOR = 21;
2561
+ const ON_DESTROY_HOOKS = 22;
2552
2562
  /**
2553
2563
  * Size of LView's header. Necessary to adjust for it when setting slots.
2554
2564
  *
@@ -2556,7 +2566,7 @@ const EMBEDDED_VIEW_INJECTOR = 21;
2556
2566
  * instruction index into `LView` index. All other indexes should be in the `LView` index space and
2557
2567
  * there should be no need to refer to `HEADER_OFFSET` anywhere else.
2558
2568
  */
2559
- const HEADER_OFFSET = 22;
2569
+ const HEADER_OFFSET = 23;
2560
2570
  // Note: This hack is necessary so we don't erroneously get a circular dependency
2561
2571
  // failure based on types.
2562
2572
  const unusedValueExportToPlacateAjd$4 = 1;
@@ -3032,6 +3042,15 @@ function updateTransplantedViewCount(lContainer, amount) {
3032
3042
  parent = parent[PARENT];
3033
3043
  }
3034
3044
  }
3045
+ /**
3046
+ * Stores a LView-specific destroy callback.
3047
+ */
3048
+ function storeLViewOnDestroy(lView, onDestroyCallback) {
3049
+ if (lView[ON_DESTROY_HOOKS] === null) {
3050
+ lView[ON_DESTROY_HOOKS] = [];
3051
+ }
3052
+ lView[ON_DESTROY_HOOKS].push(onDestroyCallback);
3053
+ }
3035
3054
 
3036
3055
  const instructionState = {
3037
3056
  lFrame: createLFrame(null),
@@ -3709,8 +3728,9 @@ function callHooks(currentView, arr, initPhase, currentNodeIndex) {
3709
3728
  }
3710
3729
  else {
3711
3730
  const isInitHook = arr[i] < 0;
3712
- if (isInitHook)
3731
+ if (isInitHook) {
3713
3732
  currentView[PREORDER_HOOK_FLAGS] += 65536 /* PreOrderHookFlags.NumberOfInitHooksCalledIncrementer */;
3733
+ }
3714
3734
  if (lastNodeIndexFound < nodeIndexLimit || nodeIndexLimit == -1) {
3715
3735
  callHook(currentView, initPhase, arr, i);
3716
3736
  currentView[PREORDER_HOOK_FLAGS] =
@@ -6241,10 +6261,6 @@ function cleanUpView(tView, lView) {
6241
6261
  function processCleanups(tView, lView) {
6242
6262
  const tCleanup = tView.cleanup;
6243
6263
  const lCleanup = lView[CLEANUP];
6244
- // `LCleanup` contains both share information with `TCleanup` as well as instance specific
6245
- // information appended at the end. We need to know where the end of the `TCleanup` information
6246
- // is, and we track this with `lastLCleanupIndex`.
6247
- let lastLCleanupIndex = -1;
6248
6264
  if (tCleanup !== null) {
6249
6265
  for (let i = 0; i < tCleanup.length - 1; i += 2) {
6250
6266
  if (typeof tCleanup[i] === 'string') {
@@ -6254,29 +6270,33 @@ function processCleanups(tView, lView) {
6254
6270
  ngDevMode && assertNumber(targetIdx, 'cleanup target must be a number');
6255
6271
  if (targetIdx >= 0) {
6256
6272
  // unregister
6257
- lCleanup[lastLCleanupIndex = targetIdx]();
6273
+ lCleanup[targetIdx]();
6258
6274
  }
6259
6275
  else {
6260
6276
  // Subscription
6261
- lCleanup[lastLCleanupIndex = -targetIdx].unsubscribe();
6277
+ lCleanup[-targetIdx].unsubscribe();
6262
6278
  }
6263
6279
  i += 2;
6264
6280
  }
6265
6281
  else {
6266
6282
  // This is a cleanup function that is grouped with the index of its context
6267
- const context = lCleanup[lastLCleanupIndex = tCleanup[i + 1]];
6283
+ const context = lCleanup[tCleanup[i + 1]];
6268
6284
  tCleanup[i].call(context);
6269
6285
  }
6270
6286
  }
6271
6287
  }
6272
6288
  if (lCleanup !== null) {
6273
- for (let i = lastLCleanupIndex + 1; i < lCleanup.length; i++) {
6274
- const instanceCleanupFn = lCleanup[i];
6275
- ngDevMode && assertFunction(instanceCleanupFn, 'Expecting instance cleanup function.');
6276
- instanceCleanupFn();
6277
- }
6278
6289
  lView[CLEANUP] = null;
6279
6290
  }
6291
+ const destroyHooks = lView[ON_DESTROY_HOOKS];
6292
+ if (destroyHooks !== null) {
6293
+ for (let i = 0; i < destroyHooks.length; i++) {
6294
+ const destroyHooksFn = destroyHooks[i];
6295
+ ngDevMode && assertFunction(destroyHooksFn, 'Expecting destroy hook to be a function.');
6296
+ destroyHooksFn();
6297
+ }
6298
+ lView[ON_DESTROY_HOOKS] = null;
6299
+ }
6280
6300
  }
6281
6301
  /** Calls onDestroy hooks for this view */
6282
6302
  function executeOnDestroys(tView, lView) {
@@ -8286,6 +8306,9 @@ class R3Injector extends EnvironmentInjector {
8286
8306
  }
8287
8307
  get(token, notFoundValue = THROW_IF_NOT_FOUND, flags = InjectFlags.Default) {
8288
8308
  this.assertNotDestroyed();
8309
+ if (token.hasOwnProperty(NG_ENV_ID)) {
8310
+ return token[NG_ENV_ID](this);
8311
+ }
8289
8312
  flags = convertToBitFlags(flags);
8290
8313
  // Set the injection context.
8291
8314
  const previousInjector = setCurrentInjector(this);
@@ -8742,7 +8765,7 @@ class Version {
8742
8765
  /**
8743
8766
  * @publicApi
8744
8767
  */
8745
- const VERSION = new Version('16.0.0-next.0');
8768
+ const VERSION = new Version('16.0.0-next.1');
8746
8769
 
8747
8770
  // This default value is when checking the hierarchy for a token.
8748
8771
  //
@@ -10555,6 +10578,7 @@ function createTNodeAtIndex(tView, index, type, name, attrs) {
10555
10578
  // In the case of i18n the `currentTNode` may already be linked, in which case we don't want
10556
10579
  // to break the links which i18n created.
10557
10580
  currentTNode.next = tNode;
10581
+ tNode.prev = currentTNode;
10558
10582
  }
10559
10583
  }
10560
10584
  }
@@ -10945,24 +10969,24 @@ function locateHostElement(renderer, elementOrSelector, encapsulation) {
10945
10969
  * On the first template pass, saves in TView:
10946
10970
  * - Cleanup function
10947
10971
  * - Index of context we just saved in LView.cleanupInstances
10948
- *
10949
- * This function can also be used to store instance specific cleanup fns. In that case the `context`
10950
- * is `null` and the function is store in `LView` (rather than it `TView`).
10951
10972
  */
10952
10973
  function storeCleanupWithContext(tView, lView, context, cleanupFn) {
10953
10974
  const lCleanup = getOrCreateLViewCleanup(lView);
10954
- if (context === null) {
10955
- // If context is null that this is instance specific callback. These callbacks can only be
10956
- // inserted after template shared instances. For this reason in ngDevMode we freeze the TView.
10957
- if (ngDevMode) {
10958
- Object.freeze(getOrCreateTViewCleanup(tView));
10959
- }
10960
- lCleanup.push(cleanupFn);
10975
+ // Historically the `storeCleanupWithContext` was used to register both framework-level and
10976
+ // user-defined cleanup callbacks, but over time those two types of cleanups were separated. This
10977
+ // dev mode checks assures that user-level cleanup callbacks are _not_ stored in data structures
10978
+ // reserved for framework-specific hooks.
10979
+ ngDevMode &&
10980
+ assertDefined(context, 'Cleanup context is mandatory when registering framework-level destroy hooks');
10981
+ lCleanup.push(context);
10982
+ if (tView.firstCreatePass) {
10983
+ getOrCreateTViewCleanup(tView).push(cleanupFn, lCleanup.length - 1);
10961
10984
  }
10962
10985
  else {
10963
- lCleanup.push(context);
10964
- if (tView.firstCreatePass) {
10965
- getOrCreateTViewCleanup(tView).push(cleanupFn, lCleanup.length - 1);
10986
+ // Make sure that no new framework-level cleanup functions are registered after the first
10987
+ // template pass is done (and TView data structures are meant to fully constructed).
10988
+ if (ngDevMode) {
10989
+ Object.freeze(getOrCreateTViewCleanup(tView));
10966
10990
  }
10967
10991
  }
10968
10992
  }
@@ -10995,6 +11019,7 @@ function createTNode(tView, tParent, type, index, value, attrs) {
10995
11019
  outputs: null,
10996
11020
  tViews: null,
10997
11021
  next: null,
11022
+ prev: null,
10998
11023
  projectionNext: null,
10999
11024
  child: null,
11000
11025
  parent: tParent,
@@ -11204,7 +11229,6 @@ function resolveDirectives(tView, lView, tNode, localRefs) {
11204
11229
  // Please make sure to have explicit type for `exportsMap`. Inferred type triggers bug in
11205
11230
  // tsickle.
11206
11231
  ngDevMode && assertFirstCreatePass(tView);
11207
- let hasDirectives = false;
11208
11232
  if (getBindingsEnabled()) {
11209
11233
  const exportsMap = localRefs === null ? null : { '': -1 };
11210
11234
  const matchResult = findDirectiveDefMatches(tView, tNode);
@@ -11217,7 +11241,6 @@ function resolveDirectives(tView, lView, tNode, localRefs) {
11217
11241
  [directiveDefs, hostDirectiveDefs] = matchResult;
11218
11242
  }
11219
11243
  if (directiveDefs !== null) {
11220
- hasDirectives = true;
11221
11244
  initializeDirectives(tView, lView, tNode, directiveDefs, exportsMap, hostDirectiveDefs);
11222
11245
  }
11223
11246
  if (exportsMap)
@@ -11225,7 +11248,6 @@ function resolveDirectives(tView, lView, tNode, localRefs) {
11225
11248
  }
11226
11249
  // Merge the template attrs last so that they have the highest priority.
11227
11250
  tNode.mergedAttrs = mergeHostAttrs(tNode.mergedAttrs, tNode.attrs);
11228
- return hasDirectives;
11229
11251
  }
11230
11252
  /** Initializes the data structures necessary for a list of directives to be instantiated. */
11231
11253
  function initializeDirectives(tView, lView, tNode, directives, exportsMap, hostDirectiveDefs) {
@@ -12156,7 +12178,7 @@ class ViewRef {
12156
12178
  destroyLView(this._lView[TVIEW], this._lView);
12157
12179
  }
12158
12180
  onDestroy(callback) {
12159
- storeCleanupWithContext(this._lView[TVIEW], this._lView, null, callback);
12181
+ storeLViewOnDestroy(this._lView, callback);
12160
12182
  }
12161
12183
  /**
12162
12184
  * Marks a view and all of its ancestors dirty.
@@ -13091,41 +13113,19 @@ function validateMappings(bindingType, def, hostDirectiveBindings) {
13091
13113
  }
13092
13114
  }
13093
13115
 
13094
- let _symbolIterator = null;
13095
- function getSymbolIterator() {
13096
- if (!_symbolIterator) {
13097
- const Symbol = _global$1['Symbol'];
13098
- if (Symbol && Symbol.iterator) {
13099
- _symbolIterator = Symbol.iterator;
13100
- }
13101
- else {
13102
- // es6-shim specific logic
13103
- const keys = Object.getOwnPropertyNames(Map.prototype);
13104
- for (let i = 0; i < keys.length; ++i) {
13105
- const key = keys[i];
13106
- if (key !== 'entries' && key !== 'size' &&
13107
- Map.prototype[key] === Map.prototype['entries']) {
13108
- _symbolIterator = key;
13109
- }
13110
- }
13111
- }
13112
- }
13113
- return _symbolIterator;
13114
- }
13115
-
13116
13116
  function isIterable(obj) {
13117
- return obj !== null && typeof obj === 'object' && obj[getSymbolIterator()] !== undefined;
13117
+ return obj !== null && typeof obj === 'object' && obj[Symbol.iterator] !== undefined;
13118
13118
  }
13119
13119
  function isListLikeIterable(obj) {
13120
13120
  if (!isJsObject(obj))
13121
13121
  return false;
13122
13122
  return Array.isArray(obj) ||
13123
13123
  (!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
13124
- getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
13124
+ Symbol.iterator in obj); // JS Iterable have a Symbol.iterator prop
13125
13125
  }
13126
13126
  function areIterablesEqual(a, b, comparator) {
13127
- const iterator1 = a[getSymbolIterator()]();
13128
- const iterator2 = b[getSymbolIterator()]();
13127
+ const iterator1 = a[Symbol.iterator]();
13128
+ const iterator2 = b[Symbol.iterator]();
13129
13129
  while (true) {
13130
13130
  const item1 = iterator1.next();
13131
13131
  const item2 = iterator2.next();
@@ -13144,7 +13144,7 @@ function iterateListLike(obj, fn) {
13144
13144
  }
13145
13145
  }
13146
13146
  else {
13147
- const iterator = obj[getSymbolIterator()]();
13147
+ const iterator = obj[Symbol.iterator]();
13148
13148
  let item;
13149
13149
  while (!((item = iterator.next()).done)) {
13150
13150
  fn(item.value);
@@ -13907,16 +13907,13 @@ function setDirectiveInputsWhichShadowsStyling(tView, tNode, lView, value, isCla
13907
13907
  setInputsForProperty(tView, lView, inputs[property], property, value);
13908
13908
  }
13909
13909
 
13910
- function elementStartFirstCreatePass(index, tView, lView, native, name, attrsIndex, localRefsIndex) {
13910
+ function elementStartFirstCreatePass(index, tView, lView, name, attrsIndex, localRefsIndex) {
13911
13911
  ngDevMode && assertFirstCreatePass(tView);
13912
13912
  ngDevMode && ngDevMode.firstCreatePass++;
13913
13913
  const tViewConsts = tView.consts;
13914
13914
  const attrs = getConstant(tViewConsts, attrsIndex);
13915
13915
  const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, name, attrs);
13916
- const hasDirectives = resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex));
13917
- if (ngDevMode) {
13918
- validateElementIsKnown(native, lView, tNode.value, tView.schemas, hasDirectives);
13919
- }
13916
+ resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex));
13920
13917
  if (tNode.attrs !== null) {
13921
13918
  computeStaticStyling(tNode, tNode.attrs, false);
13922
13919
  }
@@ -13951,10 +13948,14 @@ function ɵɵelementStart(index, name, attrsIndex, localRefsIndex) {
13951
13948
  assertEqual(getBindingIndex(), tView.bindingStartIndex, 'elements should be created before any bindings');
13952
13949
  ngDevMode && assertIndexInRange(lView, adjustedIndex);
13953
13950
  const renderer = lView[RENDERER];
13954
- const native = lView[adjustedIndex] = createElementNode(renderer, name, getNamespace$1());
13955
13951
  const tNode = tView.firstCreatePass ?
13956
- elementStartFirstCreatePass(adjustedIndex, tView, lView, native, name, attrsIndex, localRefsIndex) :
13952
+ elementStartFirstCreatePass(adjustedIndex, tView, lView, name, attrsIndex, localRefsIndex) :
13957
13953
  tView.data[adjustedIndex];
13954
+ const native = lView[adjustedIndex] = createElementNode(renderer, name, getNamespace$1());
13955
+ const hasDirectives = isDirectiveHost(tNode);
13956
+ if (ngDevMode && tView.firstCreatePass) {
13957
+ validateElementIsKnown(native, lView, tNode.value, tView.schemas, hasDirectives);
13958
+ }
13958
13959
  setCurrentTNode(tNode, true);
13959
13960
  setupStaticAttributes(renderer, native, tNode);
13960
13961
  if ((tNode.flags & 32 /* TNodeFlags.isDetached */) !== 32 /* TNodeFlags.isDetached */) {
@@ -13969,7 +13970,7 @@ function ɵɵelementStart(index, name, attrsIndex, localRefsIndex) {
13969
13970
  attachPatchData(native, lView);
13970
13971
  }
13971
13972
  increaseElementDepthCount();
13972
- if (isDirectiveHost(tNode)) {
13973
+ if (hasDirectives) {
13973
13974
  createDirectivesInstances(tView, lView, tNode);
13974
13975
  executeContentQueries(tView, tNode, lView);
13975
13976
  }
@@ -21284,7 +21285,8 @@ function _wrapInTimeout(fn) {
21284
21285
  const EventEmitter = EventEmitter_;
21285
21286
 
21286
21287
  function symbolIterator() {
21287
- return this._results[getSymbolIterator()]();
21288
+ // @ts-expect-error accessing a private member
21289
+ return this._results[Symbol.iterator]();
21288
21290
  }
21289
21291
  /**
21290
21292
  * An unmodifiable list of items that Angular keeps up to date when the state
@@ -21336,11 +21338,10 @@ class QueryList {
21336
21338
  // This function should be declared on the prototype, but doing so there will cause the class
21337
21339
  // declaration to have side-effects and become not tree-shakable. For this reason we do it in
21338
21340
  // the constructor.
21339
- // [getSymbolIterator()](): Iterator<T> { ... }
21340
- const symbol = getSymbolIterator();
21341
+ // [Symbol.iterator](): Iterator<T> { ... }
21341
21342
  const proto = QueryList.prototype;
21342
- if (!proto[symbol])
21343
- proto[symbol] = symbolIterator;
21343
+ if (!proto[Symbol.iterator])
21344
+ proto[Symbol.iterator] = symbolIterator;
21344
21345
  }
21345
21346
  /**
21346
21347
  * Returns the QueryList entry at `index`.