@angular/core 16.0.1 → 16.1.0-next.0
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.
- package/esm2022/src/compiler/compiler_facade_interface.mjs +1 -1
- package/esm2022/src/linker/template_ref.mjs +6 -3
- package/esm2022/src/metadata/directives.mjs +1 -1
- package/esm2022/src/render3/component.mjs +4 -1
- package/esm2022/src/render3/component_ref.mjs +14 -3
- package/esm2022/src/render3/definition.mjs +4 -1
- package/esm2022/src/render3/di.mjs +2 -2
- package/esm2022/src/render3/hooks.mjs +3 -3
- package/esm2022/src/render3/instructions/change_detection.mjs +37 -53
- package/esm2022/src/render3/instructions/shared.mjs +9 -2
- package/esm2022/src/render3/interfaces/definition.mjs +1 -1
- package/esm2022/src/render3/interfaces/public_definitions.mjs +1 -1
- package/esm2022/src/render3/interfaces/view.mjs +1 -1
- package/esm2022/src/render3/jit/directive.mjs +2 -1
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/logger.mjs +3 -3
- package/fesm2022/core.mjs +73 -61
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +69 -61
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +19 -6
- package/package.json +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/ng-generate/standalone-migration/bundle.js +208 -59
- package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
- package/testing/index.d.ts +1 -1
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v16.0.
|
|
2
|
+
* @license Angular v16.1.0-next.0
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -2871,6 +2871,7 @@ function ɵɵdefineComponent(componentDefinition) {
|
|
|
2871
2871
|
pipeDefs: null,
|
|
2872
2872
|
dependencies: baseDef.standalone && componentDefinition.dependencies || null,
|
|
2873
2873
|
getStandaloneInjector: null,
|
|
2874
|
+
signals: componentDefinition.signals ?? false,
|
|
2874
2875
|
data: componentDefinition.data || {},
|
|
2875
2876
|
encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated,
|
|
2876
2877
|
styles: componentDefinition.styles || EMPTY_ARRAY,
|
|
@@ -3113,6 +3114,7 @@ function getNgDirectiveDef(directiveDefinition) {
|
|
|
3113
3114
|
declaredInputs,
|
|
3114
3115
|
exportAs: directiveDefinition.exportAs || null,
|
|
3115
3116
|
standalone: directiveDefinition.standalone === true,
|
|
3117
|
+
signals: directiveDefinition.signals === true,
|
|
3116
3118
|
selectors: directiveDefinition.selectors || EMPTY_ARRAY,
|
|
3117
3119
|
viewQuery: directiveDefinition.viewQuery || null,
|
|
3118
3120
|
features: directiveDefinition.features || null,
|
|
@@ -3164,6 +3166,7 @@ function getComponentId(componentDef) {
|
|
|
3164
3166
|
componentDef.decls,
|
|
3165
3167
|
componentDef.encapsulation,
|
|
3166
3168
|
componentDef.standalone,
|
|
3169
|
+
componentDef.signals,
|
|
3167
3170
|
componentDef.exportAs,
|
|
3168
3171
|
componentDef.inputs,
|
|
3169
3172
|
componentDef.outputs,
|
|
@@ -5005,7 +5008,7 @@ function incrementInitPhaseFlags(lView, initPhase) {
|
|
|
5005
5008
|
assertNotEqual(initPhase, 3 /* InitPhaseState.InitPhaseCompleted */, 'Init hooks phase should not be incremented after all init hooks have been run.');
|
|
5006
5009
|
let flags = lView[FLAGS];
|
|
5007
5010
|
if ((flags & 3 /* LViewFlags.InitPhaseStateMask */) === initPhase) {
|
|
5008
|
-
flags &=
|
|
5011
|
+
flags &= 8191 /* LViewFlags.IndexWithinInitPhaseReset */;
|
|
5009
5012
|
flags += 1 /* LViewFlags.InitPhaseStateIncrementer */;
|
|
5010
5013
|
lView[FLAGS] = flags;
|
|
5011
5014
|
}
|
|
@@ -5086,12 +5089,12 @@ function callHook(currentView, initPhase, arr, i) {
|
|
|
5086
5089
|
const directiveIndex = isInitHook ? -arr[i] : arr[i];
|
|
5087
5090
|
const directive = currentView[directiveIndex];
|
|
5088
5091
|
if (isInitHook) {
|
|
5089
|
-
const indexWithintInitPhase = currentView[FLAGS] >>
|
|
5092
|
+
const indexWithintInitPhase = currentView[FLAGS] >> 13 /* LViewFlags.IndexWithinInitPhaseShift */;
|
|
5090
5093
|
// The init phase state must be always checked here as it may have been recursively updated.
|
|
5091
5094
|
if (indexWithintInitPhase <
|
|
5092
5095
|
(currentView[PREORDER_HOOK_FLAGS] >> 16 /* PreOrderHookFlags.NumberOfInitHooksCalledShift */) &&
|
|
5093
5096
|
(currentView[FLAGS] & 3 /* LViewFlags.InitPhaseStateMask */) === initPhase) {
|
|
5094
|
-
currentView[FLAGS] +=
|
|
5097
|
+
currentView[FLAGS] += 8192 /* LViewFlags.IndexWithinInitPhaseIncrementer */;
|
|
5095
5098
|
callHookInternal(directive, hook);
|
|
5096
5099
|
}
|
|
5097
5100
|
}
|
|
@@ -5992,7 +5995,7 @@ function ɵɵgetInheritedFactory(type) {
|
|
|
5992
5995
|
// (no Angular decorator on the superclass) or there is no constructor at all
|
|
5993
5996
|
// in the inheritance chain. Since the two cases cannot be distinguished, the
|
|
5994
5997
|
// latter has to be assumed.
|
|
5995
|
-
return t => new t();
|
|
5998
|
+
return (t) => new t();
|
|
5996
5999
|
});
|
|
5997
6000
|
}
|
|
5998
6001
|
function getFactoryOf(type) {
|
|
@@ -10443,7 +10446,7 @@ class Version {
|
|
|
10443
10446
|
/**
|
|
10444
10447
|
* @publicApi
|
|
10445
10448
|
*/
|
|
10446
|
-
const VERSION = new Version('16.0.
|
|
10449
|
+
const VERSION = new Version('16.1.0-next.0');
|
|
10447
10450
|
|
|
10448
10451
|
// This default value is when checking the hierarchy for a token.
|
|
10449
10452
|
//
|
|
@@ -12061,7 +12064,14 @@ function addComponentLogic(lView, hostTNode, def) {
|
|
|
12061
12064
|
// Only component views should be added to the view tree directly. Embedded views are
|
|
12062
12065
|
// accessed through their containers because they may be removed / re-added later.
|
|
12063
12066
|
const rendererFactory = lView[ENVIRONMENT].rendererFactory;
|
|
12064
|
-
|
|
12067
|
+
let lViewFlags = 16 /* LViewFlags.CheckAlways */;
|
|
12068
|
+
if (def.signals) {
|
|
12069
|
+
lViewFlags = 4096 /* LViewFlags.SignalView */;
|
|
12070
|
+
}
|
|
12071
|
+
else if (def.onPush) {
|
|
12072
|
+
lViewFlags = 64 /* LViewFlags.Dirty */;
|
|
12073
|
+
}
|
|
12074
|
+
const componentView = addToViewTree(lView, createLView(lView, tView, null, lViewFlags, native, hostTNode, null, rendererFactory.createRenderer(native, def), null, null, null));
|
|
12065
12075
|
// Component view will always be created before any injected LContainers,
|
|
12066
12076
|
// so this is a regular element, wrap it with the component view
|
|
12067
12077
|
lView[hostTNode.index] = componentView;
|
|
@@ -12771,7 +12781,7 @@ function refreshView(tView, lView, templateFn, context) {
|
|
|
12771
12781
|
// insertion points. This is needed to avoid the situation where the template is defined in this
|
|
12772
12782
|
// `LView` but its declaration appears after the insertion component.
|
|
12773
12783
|
markTransplantedViewsForRefresh(lView);
|
|
12774
|
-
|
|
12784
|
+
detectChangesInEmbeddedViews(lView, 2 /* ChangeDetectionMode.BugToForceRefreshAndIgnoreViewFlags */);
|
|
12775
12785
|
// Content query results must be refreshed before content hooks are called.
|
|
12776
12786
|
if (tView.contentQueries !== null) {
|
|
12777
12787
|
refreshContentQueries(tView, lView);
|
|
@@ -12797,7 +12807,7 @@ function refreshView(tView, lView, templateFn, context) {
|
|
|
12797
12807
|
// Refresh child component views.
|
|
12798
12808
|
const components = tView.components;
|
|
12799
12809
|
if (components !== null) {
|
|
12800
|
-
|
|
12810
|
+
detectChangesInChildComponents(lView, components, 0 /* ChangeDetectionMode.Global */);
|
|
12801
12811
|
}
|
|
12802
12812
|
// View queries must execute after refreshing child components because a template in this view
|
|
12803
12813
|
// could be inserted in a child component. If the view query executes before child component
|
|
@@ -12851,15 +12861,11 @@ function refreshView(tView, lView, templateFn, context) {
|
|
|
12851
12861
|
* Goes over embedded views (ones created through ViewContainerRef APIs) and refreshes
|
|
12852
12862
|
* them by executing an associated template function.
|
|
12853
12863
|
*/
|
|
12854
|
-
function
|
|
12864
|
+
function detectChangesInEmbeddedViews(lView, mode) {
|
|
12855
12865
|
for (let lContainer = getFirstLContainer(lView); lContainer !== null; lContainer = getNextLContainer(lContainer)) {
|
|
12856
12866
|
for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
|
|
12857
12867
|
const embeddedLView = lContainer[i];
|
|
12858
|
-
|
|
12859
|
-
ngDevMode && assertDefined(embeddedTView, 'TView must be allocated');
|
|
12860
|
-
if (viewAttachedToChangeDetector(embeddedLView)) {
|
|
12861
|
-
refreshView(embeddedTView, embeddedLView, embeddedTView.template, embeddedLView[CONTEXT]);
|
|
12862
|
-
}
|
|
12868
|
+
detectChangesInView(embeddedLView, mode);
|
|
12863
12869
|
}
|
|
12864
12870
|
}
|
|
12865
12871
|
}
|
|
@@ -12883,65 +12889,53 @@ function markTransplantedViewsForRefresh(lView) {
|
|
|
12883
12889
|
}
|
|
12884
12890
|
}
|
|
12885
12891
|
/**
|
|
12886
|
-
*
|
|
12892
|
+
* Detects changes in a component by entering the component view and processing its bindings,
|
|
12893
|
+
* queries, etc. if it is CheckAlways, OnPush and Dirty, etc.
|
|
12887
12894
|
*
|
|
12888
12895
|
* @param componentHostIdx Element index in LView[] (adjusted for HEADER_OFFSET)
|
|
12889
12896
|
*/
|
|
12890
|
-
function
|
|
12897
|
+
function detectChangesInComponent(hostLView, componentHostIdx, mode) {
|
|
12891
12898
|
ngDevMode && assertEqual(isCreationMode(hostLView), false, 'Should be run in update mode');
|
|
12892
12899
|
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
|
|
12893
|
-
|
|
12894
|
-
if (viewAttachedToChangeDetector(componentView)) {
|
|
12895
|
-
const tView = componentView[TVIEW];
|
|
12896
|
-
if (componentView[FLAGS] & (16 /* LViewFlags.CheckAlways */ | 64 /* LViewFlags.Dirty */)) {
|
|
12897
|
-
refreshView(tView, componentView, tView.template, componentView[CONTEXT]);
|
|
12898
|
-
}
|
|
12899
|
-
else if (componentView[DESCENDANT_VIEWS_TO_REFRESH] > 0) {
|
|
12900
|
-
// Only attached components that are CheckAlways or OnPush and dirty should be refreshed
|
|
12901
|
-
refreshContainsDirtyView(componentView);
|
|
12902
|
-
}
|
|
12903
|
-
}
|
|
12900
|
+
detectChangesInView(componentView, mode);
|
|
12904
12901
|
}
|
|
12905
12902
|
/**
|
|
12906
|
-
*
|
|
12907
|
-
*
|
|
12903
|
+
* Visits a view as part of change detection traversal.
|
|
12904
|
+
*
|
|
12905
|
+
* - If the view is detached, no additional traversal happens.
|
|
12906
|
+
*
|
|
12907
|
+
* The view is refreshed if:
|
|
12908
|
+
* - If the view is CheckAlways or Dirty and ChangeDetectionMode is `Global`
|
|
12909
|
+
* - If the view has the `RefreshTransplantedView` flag
|
|
12910
|
+
*
|
|
12911
|
+
* The view is not refreshed, but descendants are traversed in `ChangeDetectionMode.Targeted` if the
|
|
12912
|
+
* view has a non-zero TRANSPLANTED_VIEWS_TO_REFRESH counter.
|
|
12908
12913
|
*
|
|
12909
|
-
* @param lView The lView which contains descendant transplanted views that need to be refreshed.
|
|
12910
12914
|
*/
|
|
12911
|
-
function
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
const embeddedLView = lContainer[i];
|
|
12915
|
-
if (viewAttachedToChangeDetector(embeddedLView)) {
|
|
12916
|
-
if (embeddedLView[FLAGS] & 1024 /* LViewFlags.RefreshView */) {
|
|
12917
|
-
const embeddedTView = embeddedLView[TVIEW];
|
|
12918
|
-
ngDevMode && assertDefined(embeddedTView, 'TView must be allocated');
|
|
12919
|
-
refreshView(embeddedTView, embeddedLView, embeddedTView.template, embeddedLView[CONTEXT]);
|
|
12920
|
-
}
|
|
12921
|
-
else if (embeddedLView[DESCENDANT_VIEWS_TO_REFRESH] > 0) {
|
|
12922
|
-
refreshContainsDirtyView(embeddedLView);
|
|
12923
|
-
}
|
|
12924
|
-
}
|
|
12925
|
-
}
|
|
12915
|
+
function detectChangesInView(lView, mode) {
|
|
12916
|
+
if (!viewAttachedToChangeDetector(lView)) {
|
|
12917
|
+
return;
|
|
12926
12918
|
}
|
|
12927
12919
|
const tView = lView[TVIEW];
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12920
|
+
if ((lView[FLAGS] & (16 /* LViewFlags.CheckAlways */ | 64 /* LViewFlags.Dirty */) &&
|
|
12921
|
+
mode === 0 /* ChangeDetectionMode.Global */) ||
|
|
12922
|
+
lView[FLAGS] & 1024 /* LViewFlags.RefreshView */ ||
|
|
12923
|
+
mode === 2 /* ChangeDetectionMode.BugToForceRefreshAndIgnoreViewFlags */) {
|
|
12924
|
+
refreshView(tView, lView, tView.template, lView[CONTEXT]);
|
|
12925
|
+
}
|
|
12926
|
+
else if (lView[DESCENDANT_VIEWS_TO_REFRESH] > 0) {
|
|
12927
|
+
detectChangesInEmbeddedViews(lView, 1 /* ChangeDetectionMode.Targeted */);
|
|
12928
|
+
const tView = lView[TVIEW];
|
|
12929
|
+
const components = tView.components;
|
|
12930
|
+
if (components !== null) {
|
|
12931
|
+
detectChangesInChildComponents(lView, components, 1 /* ChangeDetectionMode.Targeted */);
|
|
12938
12932
|
}
|
|
12939
12933
|
}
|
|
12940
12934
|
}
|
|
12941
12935
|
/** Refreshes child components in the current view (update mode). */
|
|
12942
|
-
function
|
|
12936
|
+
function detectChangesInChildComponents(hostLView, components, mode) {
|
|
12943
12937
|
for (let i = 0; i < components.length; i++) {
|
|
12944
|
-
|
|
12938
|
+
detectChangesInComponent(hostLView, components[i], mode);
|
|
12945
12939
|
}
|
|
12946
12940
|
}
|
|
12947
12941
|
|
|
@@ -13341,8 +13335,12 @@ class ComponentFactory extends ComponentFactory$1 {
|
|
|
13341
13335
|
const hostRNode = rootSelectorOrNode ?
|
|
13342
13336
|
locateHostElement(hostRenderer, rootSelectorOrNode, this.componentDef.encapsulation, rootViewInjector) :
|
|
13343
13337
|
createElementNode(hostRenderer, elementName, getNamespace(elementName));
|
|
13344
|
-
|
|
13338
|
+
// Signal components use the granular "RefreshView" for change detection
|
|
13339
|
+
const signalFlags = (4096 /* LViewFlags.SignalView */ | 512 /* LViewFlags.IsRoot */);
|
|
13340
|
+
// Non-signal components use the traditional "CheckAlways or OnPush/Dirty" change detection
|
|
13341
|
+
const nonSignalFlags = this.componentDef.onPush ? 64 /* LViewFlags.Dirty */ | 512 /* LViewFlags.IsRoot */ :
|
|
13345
13342
|
16 /* LViewFlags.CheckAlways */ | 512 /* LViewFlags.IsRoot */;
|
|
13343
|
+
const rootFlags = this.componentDef.signals ? signalFlags : nonSignalFlags;
|
|
13346
13344
|
// Create the root view. Uses empty TView and ContentTemplate.
|
|
13347
13345
|
const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null, null);
|
|
13348
13346
|
const rootLView = createLView(null, rootTView, null, rootFlags, null, null, environment, hostRenderer, rootViewInjector, null, null);
|
|
@@ -13485,7 +13483,14 @@ function createRootComponentView(tNode, hostRNode, rootComponentDef, rootDirecti
|
|
|
13485
13483
|
hydrationInfo = retrieveHydrationInfo(hostRNode, rootView[INJECTOR$1]);
|
|
13486
13484
|
}
|
|
13487
13485
|
const viewRenderer = environment.rendererFactory.createRenderer(hostRNode, rootComponentDef);
|
|
13488
|
-
|
|
13486
|
+
let lViewFlags = 16 /* LViewFlags.CheckAlways */;
|
|
13487
|
+
if (rootComponentDef.signals) {
|
|
13488
|
+
lViewFlags = 4096 /* LViewFlags.SignalView */;
|
|
13489
|
+
}
|
|
13490
|
+
else if (rootComponentDef.onPush) {
|
|
13491
|
+
lViewFlags = 64 /* LViewFlags.Dirty */;
|
|
13492
|
+
}
|
|
13493
|
+
const componentView = createLView(rootView, getOrCreateComponentTView(rootComponentDef), null, lViewFlags, rootView[tNode.index], tNode, environment, viewRenderer, null, null, hydrationInfo);
|
|
13489
13494
|
if (tView.firstCreatePass) {
|
|
13490
13495
|
markAsComponentHost(tView, tNode, rootDirectives.length - 1);
|
|
13491
13496
|
}
|
|
@@ -23222,8 +23227,11 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
|
|
|
23222
23227
|
* @internal
|
|
23223
23228
|
*/
|
|
23224
23229
|
createEmbeddedViewImpl(context, injector, hydrationInfo) {
|
|
23230
|
+
// Embedded views follow the change detection strategy of the view they're declared in.
|
|
23231
|
+
const isSignalView = this._declarationLView[FLAGS] & 4096 /* LViewFlags.SignalView */;
|
|
23232
|
+
const viewFlags = isSignalView ? 4096 /* LViewFlags.SignalView */ : 16 /* LViewFlags.CheckAlways */;
|
|
23225
23233
|
const embeddedTView = this._declarationTContainer.tView;
|
|
23226
|
-
const embeddedLView = createLView(this._declarationLView, embeddedTView, context,
|
|
23234
|
+
const embeddedLView = createLView(this._declarationLView, embeddedTView, context, viewFlags, null, embeddedTView.declTNode, null, null, null, injector || null, hydrationInfo || null);
|
|
23227
23235
|
const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
|
|
23228
23236
|
ngDevMode && assertLContainer(declarationLContainer);
|
|
23229
23237
|
embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
|