@angular/core 14.0.0-next.4 → 14.0.0-next.5

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.0.0-next.4
2
+ * @license Angular v14.0.0-next.5
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
package/fesm2020/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.0-next.4
2
+ * @license Angular v14.0.0-next.5
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1173,6 +1173,7 @@ const DECLARATION_LCONTAINER = 17;
1173
1173
  const PREORDER_HOOK_FLAGS = 18;
1174
1174
  const QUERIES = 19;
1175
1175
  const ID = 20;
1176
+ const EMBEDDED_VIEW_INJECTOR = 21;
1176
1177
  /**
1177
1178
  * Size of LView's header. Necessary to adjust for it when setting slots.
1178
1179
  *
@@ -1180,7 +1181,7 @@ const ID = 20;
1180
1181
  * instruction index into `LView` index. All other indexes should be in the `LView` index space and
1181
1182
  * there should be no need to refer to `HEADER_OFFSET` anywhere else.
1182
1183
  */
1183
- const HEADER_OFFSET = 21;
1184
+ const HEADER_OFFSET = 22;
1184
1185
  /**
1185
1186
  * Converts `TViewType` into human readable text.
1186
1187
  * Make sure this matches with `TViewType`
@@ -2475,7 +2476,7 @@ function incrementInitPhaseFlags(lView, initPhase) {
2475
2476
  assertNotEqual(initPhase, 3 /* InitPhaseCompleted */, 'Init hooks phase should not be incremented after all init hooks have been run.');
2476
2477
  let flags = lView[FLAGS];
2477
2478
  if ((flags & 3 /* InitPhaseStateMask */) === initPhase) {
2478
- flags &= 2047 /* IndexWithinInitPhaseReset */;
2479
+ flags &= 4095 /* IndexWithinInitPhaseReset */;
2479
2480
  flags += 1 /* InitPhaseStateIncrementer */;
2480
2481
  lView[FLAGS] = flags;
2481
2482
  }
@@ -2539,12 +2540,12 @@ function callHook(currentView, initPhase, arr, i) {
2539
2540
  const directiveIndex = isInitHook ? -arr[i] : arr[i];
2540
2541
  const directive = currentView[directiveIndex];
2541
2542
  if (isInitHook) {
2542
- const indexWithintInitPhase = currentView[FLAGS] >> 11 /* IndexWithinInitPhaseShift */;
2543
+ const indexWithintInitPhase = currentView[FLAGS] >> 12 /* IndexWithinInitPhaseShift */;
2543
2544
  // The init phase state must be always checked here as it may have been recursively updated.
2544
2545
  if (indexWithintInitPhase <
2545
2546
  (currentView[PREORDER_HOOK_FLAGS] >> 16 /* NumberOfInitHooksCalledShift */) &&
2546
2547
  (currentView[FLAGS] & 3 /* InitPhaseStateMask */) === initPhase) {
2547
- currentView[FLAGS] += 2048 /* IndexWithinInitPhaseIncrementer */;
2548
+ currentView[FLAGS] += 4096 /* IndexWithinInitPhaseIncrementer */;
2548
2549
  profiler(4 /* LifecycleHookStart */, directive, hook);
2549
2550
  try {
2550
2551
  hook.call(directive);
@@ -3105,6 +3106,8 @@ const BLOOM_MASK = BLOOM_SIZE - 1;
3105
3106
  const BLOOM_BUCKET_BITS = 5;
3106
3107
  /** Counter used to generate unique IDs for directives. */
3107
3108
  let nextNgElementId = 0;
3109
+ /** Value used when something wasn't found by an injector. */
3110
+ const NOT_FOUND = {};
3108
3111
  /**
3109
3112
  * Registers this directive as present in its node's injector by flipping the directive's
3110
3113
  * corresponding bit in the injector's bloom filter.
@@ -3216,23 +3219,7 @@ function getParentInjectorLocation(tNode, lView) {
3216
3219
  // `LView` hierarchy and look for it. If we walk of the top, that means that there is no parent
3217
3220
  // `NodeInjector`.
3218
3221
  while (lViewCursor !== null) {
3219
- // First determine the `parentTNode` location. The parent pointer differs based on `TView.type`.
3220
- const tView = lViewCursor[TVIEW];
3221
- const tViewType = tView.type;
3222
- if (tViewType === 2 /* Embedded */) {
3223
- ngDevMode &&
3224
- assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.');
3225
- parentTNode = tView.declTNode;
3226
- }
3227
- else if (tViewType === 1 /* Component */) {
3228
- // Components don't have `TView.declTNode` because each instance of component could be
3229
- // inserted in different location, hence `TView.declTNode` is meaningless.
3230
- parentTNode = lViewCursor[T_HOST];
3231
- }
3232
- else {
3233
- ngDevMode && assertEqual(tView.type, 0 /* Root */, 'Root type expected');
3234
- parentTNode = null;
3235
- }
3222
+ parentTNode = getTNodeFromLView(lViewCursor);
3236
3223
  if (parentTNode === null) {
3237
3224
  // If we have no parent, than we are done.
3238
3225
  return NO_PARENT_INJECTOR;
@@ -3393,93 +3380,116 @@ function lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue) {
3393
3380
  */
3394
3381
  function getOrCreateInjectable(tNode, lView, token, flags = InjectFlags.Default, notFoundValue) {
3395
3382
  if (tNode !== null) {
3396
- const bloomHash = bloomHashBitOrFactory(token);
3397
- // If the ID stored here is a function, this is a special object like ElementRef or TemplateRef
3398
- // so just call the factory function to create it.
3399
- if (typeof bloomHash === 'function') {
3400
- if (!enterDI(lView, tNode, flags)) {
3401
- // Failed to enter DI, try module injector instead. If a token is injected with the @Host
3402
- // flag, the module injector is not searched for that token in Ivy.
3403
- return (flags & InjectFlags.Host) ?
3404
- notFoundValueOrThrow(notFoundValue, token, flags) :
3405
- lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
3383
+ // If the view or any of its ancestors have an embedded
3384
+ // view injector, we have to look it up there first.
3385
+ if (lView[FLAGS] & 2048 /* HasEmbeddedViewInjector */) {
3386
+ const embeddedInjectorValue = lookupTokenUsingEmbeddedInjector(tNode, lView, token, flags, NOT_FOUND);
3387
+ if (embeddedInjectorValue !== NOT_FOUND) {
3388
+ return embeddedInjectorValue;
3406
3389
  }
3407
- try {
3408
- const value = bloomHash(flags);
3409
- if (value == null && !(flags & InjectFlags.Optional)) {
3410
- throwProviderNotFoundError(token);
3411
- }
3412
- else {
3413
- return value;
3414
- }
3390
+ }
3391
+ // Otherwise try the node injector.
3392
+ const value = lookupTokenUsingNodeInjector(tNode, lView, token, flags, NOT_FOUND);
3393
+ if (value !== NOT_FOUND) {
3394
+ return value;
3395
+ }
3396
+ }
3397
+ // Finally, fall back to the module injector.
3398
+ return lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
3399
+ }
3400
+ /**
3401
+ * Returns the value associated to the given token from the node injector.
3402
+ *
3403
+ * @param tNode The Node where the search for the injector should start
3404
+ * @param lView The `LView` that contains the `tNode`
3405
+ * @param token The token to look for
3406
+ * @param flags Injection flags
3407
+ * @param notFoundValue The value to return when the injection flags is `InjectFlags.Optional`
3408
+ * @returns the value from the injector, `null` when not found, or `notFoundValue` if provided
3409
+ */
3410
+ function lookupTokenUsingNodeInjector(tNode, lView, token, flags, notFoundValue) {
3411
+ const bloomHash = bloomHashBitOrFactory(token);
3412
+ // If the ID stored here is a function, this is a special object like ElementRef or TemplateRef
3413
+ // so just call the factory function to create it.
3414
+ if (typeof bloomHash === 'function') {
3415
+ if (!enterDI(lView, tNode, flags)) {
3416
+ // Failed to enter DI, try module injector instead. If a token is injected with the @Host
3417
+ // flag, the module injector is not searched for that token in Ivy.
3418
+ return (flags & InjectFlags.Host) ?
3419
+ notFoundValueOrThrow(notFoundValue, token, flags) :
3420
+ lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
3421
+ }
3422
+ try {
3423
+ const value = bloomHash(flags);
3424
+ if (value == null && !(flags & InjectFlags.Optional)) {
3425
+ throwProviderNotFoundError(token);
3415
3426
  }
3416
- finally {
3417
- leaveDI();
3418
- }
3419
- }
3420
- else if (typeof bloomHash === 'number') {
3421
- // A reference to the previous injector TView that was found while climbing the element
3422
- // injector tree. This is used to know if viewProviders can be accessed on the current
3423
- // injector.
3424
- let previousTView = null;
3425
- let injectorIndex = getInjectorIndex(tNode, lView);
3426
- let parentLocation = NO_PARENT_INJECTOR;
3427
- let hostTElementNode = flags & InjectFlags.Host ? lView[DECLARATION_COMPONENT_VIEW][T_HOST] : null;
3428
- // If we should skip this injector, or if there is no injector on this node, start by
3429
- // searching the parent injector.
3430
- if (injectorIndex === -1 || flags & InjectFlags.SkipSelf) {
3431
- parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lView) :
3432
- lView[injectorIndex + 8 /* PARENT */];
3433
- if (parentLocation === NO_PARENT_INJECTOR || !shouldSearchParent(flags, false)) {
3434
- injectorIndex = -1;
3435
- }
3436
- else {
3437
- previousTView = lView[TVIEW];
3438
- injectorIndex = getParentInjectorIndex(parentLocation);
3439
- lView = getParentInjectorView(parentLocation, lView);
3440
- }
3427
+ else {
3428
+ return value;
3441
3429
  }
3442
- // Traverse up the injector tree until we find a potential match or until we know there
3443
- // *isn't* a match.
3444
- while (injectorIndex !== -1) {
3445
- ngDevMode && assertNodeInjector(lView, injectorIndex);
3446
- // Check the current injector. If it matches, see if it contains token.
3447
- const tView = lView[TVIEW];
3448
- ngDevMode &&
3449
- assertTNodeForLView(tView.data[injectorIndex + 8 /* TNODE */], lView);
3450
- if (bloomHasToken(bloomHash, injectorIndex, tView.data)) {
3451
- // At this point, we have an injector which *may* contain the token, so we step through
3452
- // the providers and directives associated with the injector's corresponding node to get
3453
- // the instance.
3454
- const instance = searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode);
3455
- if (instance !== NOT_FOUND) {
3456
- return instance;
3457
- }
3458
- }
3459
- parentLocation = lView[injectorIndex + 8 /* PARENT */];
3460
- if (parentLocation !== NO_PARENT_INJECTOR &&
3461
- shouldSearchParent(flags, lView[TVIEW].data[injectorIndex + 8 /* TNODE */] === hostTElementNode) &&
3462
- bloomHasToken(bloomHash, injectorIndex, lView)) {
3463
- // The def wasn't found anywhere on this node, so it was a false positive.
3464
- // Traverse up the tree and continue searching.
3465
- previousTView = tView;
3466
- injectorIndex = getParentInjectorIndex(parentLocation);
3467
- lView = getParentInjectorView(parentLocation, lView);
3468
- }
3469
- else {
3470
- // If we should not search parent OR If the ancestor bloom filter value does not have the
3471
- // bit corresponding to the directive we can give up on traversing up to find the specific
3472
- // injector.
3473
- injectorIndex = -1;
3430
+ }
3431
+ finally {
3432
+ leaveDI();
3433
+ }
3434
+ }
3435
+ else if (typeof bloomHash === 'number') {
3436
+ // A reference to the previous injector TView that was found while climbing the element
3437
+ // injector tree. This is used to know if viewProviders can be accessed on the current
3438
+ // injector.
3439
+ let previousTView = null;
3440
+ let injectorIndex = getInjectorIndex(tNode, lView);
3441
+ let parentLocation = NO_PARENT_INJECTOR;
3442
+ let hostTElementNode = flags & InjectFlags.Host ? lView[DECLARATION_COMPONENT_VIEW][T_HOST] : null;
3443
+ // If we should skip this injector, or if there is no injector on this node, start by
3444
+ // searching the parent injector.
3445
+ if (injectorIndex === -1 || flags & InjectFlags.SkipSelf) {
3446
+ parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lView) :
3447
+ lView[injectorIndex + 8 /* PARENT */];
3448
+ if (parentLocation === NO_PARENT_INJECTOR || !shouldSearchParent(flags, false)) {
3449
+ injectorIndex = -1;
3450
+ }
3451
+ else {
3452
+ previousTView = lView[TVIEW];
3453
+ injectorIndex = getParentInjectorIndex(parentLocation);
3454
+ lView = getParentInjectorView(parentLocation, lView);
3455
+ }
3456
+ }
3457
+ // Traverse up the injector tree until we find a potential match or until we know there
3458
+ // *isn't* a match.
3459
+ while (injectorIndex !== -1) {
3460
+ ngDevMode && assertNodeInjector(lView, injectorIndex);
3461
+ // Check the current injector. If it matches, see if it contains token.
3462
+ const tView = lView[TVIEW];
3463
+ ngDevMode &&
3464
+ assertTNodeForLView(tView.data[injectorIndex + 8 /* TNODE */], lView);
3465
+ if (bloomHasToken(bloomHash, injectorIndex, tView.data)) {
3466
+ // At this point, we have an injector which *may* contain the token, so we step through
3467
+ // the providers and directives associated with the injector's corresponding node to get
3468
+ // the instance.
3469
+ const instance = searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode);
3470
+ if (instance !== NOT_FOUND) {
3471
+ return instance;
3474
3472
  }
3475
3473
  }
3474
+ parentLocation = lView[injectorIndex + 8 /* PARENT */];
3475
+ if (parentLocation !== NO_PARENT_INJECTOR &&
3476
+ shouldSearchParent(flags, lView[TVIEW].data[injectorIndex + 8 /* TNODE */] === hostTElementNode) &&
3477
+ bloomHasToken(bloomHash, injectorIndex, lView)) {
3478
+ // The def wasn't found anywhere on this node, so it was a false positive.
3479
+ // Traverse up the tree and continue searching.
3480
+ previousTView = tView;
3481
+ injectorIndex = getParentInjectorIndex(parentLocation);
3482
+ lView = getParentInjectorView(parentLocation, lView);
3483
+ }
3484
+ else {
3485
+ // If we should not search parent OR If the ancestor bloom filter value does not have the
3486
+ // bit corresponding to the directive we can give up on traversing up to find the specific
3487
+ // injector.
3488
+ injectorIndex = -1;
3489
+ }
3476
3490
  }
3477
3491
  }
3478
- return lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue);
3479
- }
3480
- const NOT_FOUND = {};
3481
- function createNodeInjector() {
3482
- return new NodeInjector(getCurrentTNode(), getLView());
3492
+ return notFoundValue;
3483
3493
  }
3484
3494
  function searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode) {
3485
3495
  const currentTView = lView[TVIEW];
@@ -3653,6 +3663,10 @@ class NodeInjector {
3653
3663
  return getOrCreateInjectable(this._tNode, this._lView, token, flags, notFoundValue);
3654
3664
  }
3655
3665
  }
3666
+ /** Creates a `NodeInjector` for the current node. */
3667
+ function createNodeInjector() {
3668
+ return new NodeInjector(getCurrentTNode(), getLView());
3669
+ }
3656
3670
  /**
3657
3671
  * @codeGenApi
3658
3672
  */
@@ -3691,6 +3705,73 @@ function getFactoryOf(type) {
3691
3705
  }
3692
3706
  return getFactoryDef(type);
3693
3707
  }
3708
+ /**
3709
+ * Returns a value from the closest embedded or node injector.
3710
+ *
3711
+ * @param tNode The Node where the search for the injector should start
3712
+ * @param lView The `LView` that contains the `tNode`
3713
+ * @param token The token to look for
3714
+ * @param flags Injection flags
3715
+ * @param notFoundValue The value to return when the injection flags is `InjectFlags.Optional`
3716
+ * @returns the value from the injector, `null` when not found, or `notFoundValue` if provided
3717
+ */
3718
+ function lookupTokenUsingEmbeddedInjector(tNode, lView, token, flags, notFoundValue) {
3719
+ let currentTNode = tNode;
3720
+ let currentLView = lView;
3721
+ // When an LView with an embedded view injector is inserted, it'll likely be interlaced with
3722
+ // nodes who may have injectors (e.g. node injector -> embedded view injector -> node injector).
3723
+ // Since the bloom filters for the node injectors have already been constructed and we don't
3724
+ // have a way of extracting the records from an injector, the only way to maintain the correct
3725
+ // hierarchy when resolving the value is to walk it node-by-node while attempting to resolve
3726
+ // the token at each level.
3727
+ while (currentTNode !== null && currentLView !== null &&
3728
+ (currentLView[FLAGS] & 2048 /* HasEmbeddedViewInjector */) &&
3729
+ !(currentLView[FLAGS] & 512 /* IsRoot */)) {
3730
+ ngDevMode && assertTNodeForLView(currentTNode, currentLView);
3731
+ // Note that this lookup on the node injector is using the `Self` flag, because
3732
+ // we don't want the node injector to look at any parent injectors since we
3733
+ // may hit the embedded view injector first.
3734
+ const nodeInjectorValue = lookupTokenUsingNodeInjector(currentTNode, currentLView, token, flags | InjectFlags.Self, NOT_FOUND);
3735
+ if (nodeInjectorValue !== NOT_FOUND) {
3736
+ return nodeInjectorValue;
3737
+ }
3738
+ // Has an explicit type due to a TS bug: https://github.com/microsoft/TypeScript/issues/33191
3739
+ let parentTNode = currentTNode.parent;
3740
+ // `TNode.parent` includes the parent within the current view only. If it doesn't exist,
3741
+ // it means that we've hit the view boundary and we need to go up to the next view.
3742
+ if (!parentTNode) {
3743
+ // Before we go to the next LView, check if the token exists on the current embedded injector.
3744
+ const embeddedViewInjector = currentLView[EMBEDDED_VIEW_INJECTOR];
3745
+ if (embeddedViewInjector) {
3746
+ const embeddedViewInjectorValue = embeddedViewInjector.get(token, NOT_FOUND, flags);
3747
+ if (embeddedViewInjectorValue !== NOT_FOUND) {
3748
+ return embeddedViewInjectorValue;
3749
+ }
3750
+ }
3751
+ // Otherwise keep going up the tree.
3752
+ parentTNode = getTNodeFromLView(currentLView);
3753
+ currentLView = currentLView[DECLARATION_VIEW];
3754
+ }
3755
+ currentTNode = parentTNode;
3756
+ }
3757
+ return notFoundValue;
3758
+ }
3759
+ /** Gets the TNode associated with an LView inside of the declaration view. */
3760
+ function getTNodeFromLView(lView) {
3761
+ const tView = lView[TVIEW];
3762
+ const tViewType = tView.type;
3763
+ // The parent pointer differs based on `TView.type`.
3764
+ if (tViewType === 2 /* Embedded */) {
3765
+ ngDevMode && assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.');
3766
+ return tView.declTNode;
3767
+ }
3768
+ else if (tViewType === 1 /* Component */) {
3769
+ // Components don't have `TView.declTNode` because each instance of component could be
3770
+ // inserted in different location, hence `TView.declTNode` is meaningless.
3771
+ return lView[T_HOST];
3772
+ }
3773
+ return null;
3774
+ }
3694
3775
 
3695
3776
  /**
3696
3777
  * @license
@@ -6182,11 +6263,14 @@ function getSanitizer() {
6182
6263
  const TRACKED_LVIEWS = new Map();
6183
6264
  // Used for generating unique IDs for LViews.
6184
6265
  let uniqueIdCounter = 0;
6185
- /** Starts tracking an LView and returns a unique ID that can be used for future lookups. */
6266
+ /** Gets a unique ID that can be assigned to an LView. */
6267
+ function getUniqueLViewId() {
6268
+ return uniqueIdCounter++;
6269
+ }
6270
+ /** Starts tracking an LView. */
6186
6271
  function registerLView(lView) {
6187
- const id = uniqueIdCounter++;
6188
- TRACKED_LVIEWS.set(id, lView);
6189
- return id;
6272
+ ngDevMode && assertNumber(lView[ID], 'LView must have an ID in order to be registered');
6273
+ TRACKED_LVIEWS.set(lView[ID], lView);
6190
6274
  }
6191
6275
  /** Gets an LView by its unique ID. */
6192
6276
  function getLViewById(id) {
@@ -6395,7 +6479,13 @@ function attachPatchData(target, data) {
6395
6479
  // Only attach the ID of the view in order to avoid memory leaks (see #41047). We only do this
6396
6480
  // for `LView`, because we have control over when an `LView` is created and destroyed, whereas
6397
6481
  // we can't know when to remove an `LContext`.
6398
- target[MONKEY_PATCH_KEY_NAME] = isLView(data) ? data[ID] : data;
6482
+ if (isLView(data)) {
6483
+ target[MONKEY_PATCH_KEY_NAME] = data[ID];
6484
+ registerLView(data);
6485
+ }
6486
+ else {
6487
+ target[MONKEY_PATCH_KEY_NAME] = data;
6488
+ }
6399
6489
  }
6400
6490
  /**
6401
6491
  * Returns the monkey-patch value data present on the target (which could be
@@ -9075,7 +9165,7 @@ class LViewDebug {
9075
9165
  attached: !!(flags & 128 /* Attached */),
9076
9166
  destroyed: !!(flags & 256 /* Destroyed */),
9077
9167
  isRoot: !!(flags & 512 /* IsRoot */),
9078
- indexWithinInitPhase: flags >> 11 /* IndexWithinInitPhaseShift */,
9168
+ indexWithinInitPhase: flags >> 12 /* IndexWithinInitPhaseShift */,
9079
9169
  };
9080
9170
  }
9081
9171
  get parent() {
@@ -9370,10 +9460,14 @@ function renderChildComponents(hostLView, components) {
9370
9460
  renderComponent$1(hostLView, components[i]);
9371
9461
  }
9372
9462
  }
9373
- function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector) {
9463
+ function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
9374
9464
  const lView = ngDevMode ? cloneToLViewFromTViewBlueprint(tView) : tView.blueprint.slice();
9375
9465
  lView[HOST] = host;
9376
9466
  lView[FLAGS] = flags | 4 /* CreationMode */ | 128 /* Attached */ | 8 /* FirstLViewPass */;
9467
+ if (embeddedViewInjector !== null ||
9468
+ (parentLView && (parentLView[FLAGS] & 2048 /* HasEmbeddedViewInjector */))) {
9469
+ lView[FLAGS] |= 2048 /* HasEmbeddedViewInjector */;
9470
+ }
9377
9471
  resetPreOrderHookFlags(lView);
9378
9472
  ngDevMode && tView.declTNode && parentLView && assertTNodeForLView(tView.declTNode, parentLView);
9379
9473
  lView[PARENT] = lView[DECLARATION_VIEW] = parentLView;
@@ -9385,7 +9479,8 @@ function createLView(parentLView, tView, context, flags, host, tHostNode, render
9385
9479
  lView[SANITIZER] = sanitizer || parentLView && parentLView[SANITIZER] || null;
9386
9480
  lView[INJECTOR$1] = injector || parentLView && parentLView[INJECTOR$1] || null;
9387
9481
  lView[T_HOST] = tHostNode;
9388
- lView[ID] = registerLView(lView);
9482
+ lView[ID] = getUniqueLViewId();
9483
+ lView[EMBEDDED_VIEW_INJECTOR] = embeddedViewInjector;
9389
9484
  ngDevMode &&
9390
9485
  assertEqual(tView.type == 2 /* Embedded */ ? parentLView !== null : true, true, 'Embedded views must have parentLView');
9391
9486
  lView[DECLARATION_COMPONENT_VIEW] =
@@ -10394,7 +10489,6 @@ function instantiateAllDirectives(tView, lView, tNode, native) {
10394
10489
  function invokeDirectivesHostBindings(tView, lView, tNode) {
10395
10490
  const start = tNode.directiveStart;
10396
10491
  const end = tNode.directiveEnd;
10397
- const firstCreatePass = tView.firstCreatePass;
10398
10492
  const elementIndex = tNode.index;
10399
10493
  const currentDirectiveIndex = getCurrentDirectiveIndex();
10400
10494
  try {
@@ -10541,7 +10635,7 @@ function addComponentLogic(lView, hostTNode, def) {
10541
10635
  // Only component views should be added to the view tree directly. Embedded views are
10542
10636
  // accessed through their containers because they may be removed / re-added later.
10543
10637
  const rendererFactory = lView[RENDERER_FACTORY];
10544
- const componentView = addToViewTree(lView, createLView(lView, tView, null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, native, hostTNode, rendererFactory, rendererFactory.createRenderer(native, def), null, null));
10638
+ const componentView = addToViewTree(lView, createLView(lView, tView, null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, native, hostTNode, rendererFactory, rendererFactory.createRenderer(native, def), null, null, null));
10545
10639
  // Component view will always be created before any injected LContainers,
10546
10640
  // so this is a regular element, wrap it with the component view
10547
10641
  lView[hostTNode.index] = componentView;
@@ -12283,7 +12377,7 @@ function renderComponent(componentType /* Type as workaround for: Microsoft/Type
12283
12377
  const rootContext = createRootContext(opts.scheduler, opts.playerHandler);
12284
12378
  const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
12285
12379
  const rootTView = createTView(0 /* Root */, null, null, 1, 0, null, null, null, null, null);
12286
- const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null);
12380
+ const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null, null);
12287
12381
  enterView(rootView);
12288
12382
  let component;
12289
12383
  try {
@@ -12338,7 +12432,7 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
12338
12432
  }
12339
12433
  }
12340
12434
  const viewRenderer = rendererFactory.createRenderer(rNode, def);
12341
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null);
12435
+ const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 64 /* Dirty */ : 16 /* CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
12342
12436
  if (tView.firstCreatePass) {
12343
12437
  diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
12344
12438
  markAsComponentHost(tView, tNode);
@@ -21186,7 +21280,7 @@ class Version {
21186
21280
  /**
21187
21281
  * @publicApi
21188
21282
  */
21189
- const VERSION = new Version('14.0.0-next.4');
21283
+ const VERSION = new Version('14.0.0-next.5');
21190
21284
 
21191
21285
  /**
21192
21286
  * @license
@@ -21591,22 +21685,28 @@ function getNamespace(elementName) {
21591
21685
  const name = elementName.toLowerCase();
21592
21686
  return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
21593
21687
  }
21594
- function createChainedInjector(rootViewInjector, moduleInjector) {
21595
- return {
21596
- get: (token, notFoundValue, flags) => {
21597
- const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21598
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21599
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21600
- // Return the value from the root element injector when
21601
- // - it provides it
21602
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21603
- // - the module injector should not be checked
21604
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21605
- return value;
21606
- }
21607
- return moduleInjector.get(token, notFoundValue, flags);
21688
+ /**
21689
+ * Injector that looks up a value using a specific injector, before falling back to the module
21690
+ * injector. Used primarily when creating components or embedded views dynamically.
21691
+ */
21692
+ class ChainedInjector {
21693
+ constructor(injector, parentInjector) {
21694
+ this.injector = injector;
21695
+ this.parentInjector = parentInjector;
21696
+ }
21697
+ get(token, notFoundValue, flags) {
21698
+ const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21699
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21700
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21701
+ // Return the value from the root element injector when
21702
+ // - it provides it
21703
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21704
+ // - the module injector should not be checked
21705
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21706
+ return value;
21608
21707
  }
21609
- };
21708
+ return this.parentInjector.get(token, notFoundValue, flags);
21709
+ }
21610
21710
  }
21611
21711
  /**
21612
21712
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
@@ -21634,7 +21734,7 @@ class ComponentFactory extends ComponentFactory$1 {
21634
21734
  }
21635
21735
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21636
21736
  ngModule = ngModule || this.ngModule;
21637
- const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21737
+ const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21638
21738
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21639
21739
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21640
21740
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -21649,7 +21749,7 @@ class ComponentFactory extends ComponentFactory$1 {
21649
21749
  const rootContext = createRootContext();
21650
21750
  // Create the root view. Uses empty TView and ContentTemplate.
21651
21751
  const rootTView = createTView(0 /* Root */, null, null, 1, 0, null, null, null, null, null);
21652
- const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector);
21752
+ const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
21653
21753
  // rootView is the parent when bootstrapping
21654
21754
  // TODO(misko): it looks like we are entering view here but we don't really need to as
21655
21755
  // `renderView` does that. However as the code is written it is needed because
@@ -22769,9 +22869,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22769
22869
  this._declarationTContainer = _declarationTContainer;
22770
22870
  this.elementRef = elementRef;
22771
22871
  }
22772
- createEmbeddedView(context) {
22872
+ createEmbeddedView(context, injector) {
22773
22873
  const embeddedTView = this._declarationTContainer.tViews;
22774
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22874
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null, injector || null);
22775
22875
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22776
22876
  ngDevMode && assertLContainer(declarationLContainer);
22777
22877
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22887,8 +22987,17 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22887
22987
  get length() {
22888
22988
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22889
22989
  }
22890
- createEmbeddedView(templateRef, context, index) {
22891
- const viewRef = templateRef.createEmbeddedView(context || {});
22990
+ createEmbeddedView(templateRef, context, indexOrOptions) {
22991
+ let index;
22992
+ let injector;
22993
+ if (typeof indexOrOptions === 'number') {
22994
+ index = indexOrOptions;
22995
+ }
22996
+ else if (indexOrOptions != null) {
22997
+ index = indexOrOptions.index;
22998
+ injector = indexOrOptions.injector;
22999
+ }
23000
+ const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22892
23001
  this.insert(viewRef, index);
22893
23002
  return viewRef;
22894
23003
  }