@angular/core 16.0.2 → 16.1.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.
- 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.1
|
|
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
|
JSON.stringify(componentDef.inputs),
|
|
3169
3172
|
JSON.stringify(componentDef.outputs),
|
|
@@ -5007,7 +5010,7 @@ function incrementInitPhaseFlags(lView, initPhase) {
|
|
|
5007
5010
|
assertNotEqual(initPhase, 3 /* InitPhaseState.InitPhaseCompleted */, 'Init hooks phase should not be incremented after all init hooks have been run.');
|
|
5008
5011
|
let flags = lView[FLAGS];
|
|
5009
5012
|
if ((flags & 3 /* LViewFlags.InitPhaseStateMask */) === initPhase) {
|
|
5010
|
-
flags &=
|
|
5013
|
+
flags &= 8191 /* LViewFlags.IndexWithinInitPhaseReset */;
|
|
5011
5014
|
flags += 1 /* LViewFlags.InitPhaseStateIncrementer */;
|
|
5012
5015
|
lView[FLAGS] = flags;
|
|
5013
5016
|
}
|
|
@@ -5088,12 +5091,12 @@ function callHook(currentView, initPhase, arr, i) {
|
|
|
5088
5091
|
const directiveIndex = isInitHook ? -arr[i] : arr[i];
|
|
5089
5092
|
const directive = currentView[directiveIndex];
|
|
5090
5093
|
if (isInitHook) {
|
|
5091
|
-
const indexWithintInitPhase = currentView[FLAGS] >>
|
|
5094
|
+
const indexWithintInitPhase = currentView[FLAGS] >> 13 /* LViewFlags.IndexWithinInitPhaseShift */;
|
|
5092
5095
|
// The init phase state must be always checked here as it may have been recursively updated.
|
|
5093
5096
|
if (indexWithintInitPhase <
|
|
5094
5097
|
(currentView[PREORDER_HOOK_FLAGS] >> 16 /* PreOrderHookFlags.NumberOfInitHooksCalledShift */) &&
|
|
5095
5098
|
(currentView[FLAGS] & 3 /* LViewFlags.InitPhaseStateMask */) === initPhase) {
|
|
5096
|
-
currentView[FLAGS] +=
|
|
5099
|
+
currentView[FLAGS] += 8192 /* LViewFlags.IndexWithinInitPhaseIncrementer */;
|
|
5097
5100
|
callHookInternal(directive, hook);
|
|
5098
5101
|
}
|
|
5099
5102
|
}
|
|
@@ -5994,7 +5997,7 @@ function ɵɵgetInheritedFactory(type) {
|
|
|
5994
5997
|
// (no Angular decorator on the superclass) or there is no constructor at all
|
|
5995
5998
|
// in the inheritance chain. Since the two cases cannot be distinguished, the
|
|
5996
5999
|
// latter has to be assumed.
|
|
5997
|
-
return t => new t();
|
|
6000
|
+
return (t) => new t();
|
|
5998
6001
|
});
|
|
5999
6002
|
}
|
|
6000
6003
|
function getFactoryOf(type) {
|
|
@@ -10434,7 +10437,7 @@ class Version {
|
|
|
10434
10437
|
/**
|
|
10435
10438
|
* @publicApi
|
|
10436
10439
|
*/
|
|
10437
|
-
const VERSION = new Version('16.0.
|
|
10440
|
+
const VERSION = new Version('16.1.0-next.1');
|
|
10438
10441
|
|
|
10439
10442
|
// This default value is when checking the hierarchy for a token.
|
|
10440
10443
|
//
|
|
@@ -12054,7 +12057,14 @@ function addComponentLogic(lView, hostTNode, def) {
|
|
|
12054
12057
|
// Only component views should be added to the view tree directly. Embedded views are
|
|
12055
12058
|
// accessed through their containers because they may be removed / re-added later.
|
|
12056
12059
|
const rendererFactory = lView[ENVIRONMENT].rendererFactory;
|
|
12057
|
-
|
|
12060
|
+
let lViewFlags = 16 /* LViewFlags.CheckAlways */;
|
|
12061
|
+
if (def.signals) {
|
|
12062
|
+
lViewFlags = 4096 /* LViewFlags.SignalView */;
|
|
12063
|
+
}
|
|
12064
|
+
else if (def.onPush) {
|
|
12065
|
+
lViewFlags = 64 /* LViewFlags.Dirty */;
|
|
12066
|
+
}
|
|
12067
|
+
const componentView = addToViewTree(lView, createLView(lView, tView, null, lViewFlags, native, hostTNode, null, rendererFactory.createRenderer(native, def), null, null, null));
|
|
12058
12068
|
// Component view will always be created before any injected LContainers,
|
|
12059
12069
|
// so this is a regular element, wrap it with the component view
|
|
12060
12070
|
lView[hostTNode.index] = componentView;
|
|
@@ -12764,7 +12774,7 @@ function refreshView(tView, lView, templateFn, context) {
|
|
|
12764
12774
|
// insertion points. This is needed to avoid the situation where the template is defined in this
|
|
12765
12775
|
// `LView` but its declaration appears after the insertion component.
|
|
12766
12776
|
markTransplantedViewsForRefresh(lView);
|
|
12767
|
-
|
|
12777
|
+
detectChangesInEmbeddedViews(lView, 2 /* ChangeDetectionMode.BugToForceRefreshAndIgnoreViewFlags */);
|
|
12768
12778
|
// Content query results must be refreshed before content hooks are called.
|
|
12769
12779
|
if (tView.contentQueries !== null) {
|
|
12770
12780
|
refreshContentQueries(tView, lView);
|
|
@@ -12790,7 +12800,7 @@ function refreshView(tView, lView, templateFn, context) {
|
|
|
12790
12800
|
// Refresh child component views.
|
|
12791
12801
|
const components = tView.components;
|
|
12792
12802
|
if (components !== null) {
|
|
12793
|
-
|
|
12803
|
+
detectChangesInChildComponents(lView, components, 0 /* ChangeDetectionMode.Global */);
|
|
12794
12804
|
}
|
|
12795
12805
|
// View queries must execute after refreshing child components because a template in this view
|
|
12796
12806
|
// could be inserted in a child component. If the view query executes before child component
|
|
@@ -12844,15 +12854,11 @@ function refreshView(tView, lView, templateFn, context) {
|
|
|
12844
12854
|
* Goes over embedded views (ones created through ViewContainerRef APIs) and refreshes
|
|
12845
12855
|
* them by executing an associated template function.
|
|
12846
12856
|
*/
|
|
12847
|
-
function
|
|
12857
|
+
function detectChangesInEmbeddedViews(lView, mode) {
|
|
12848
12858
|
for (let lContainer = getFirstLContainer(lView); lContainer !== null; lContainer = getNextLContainer(lContainer)) {
|
|
12849
12859
|
for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
|
|
12850
12860
|
const embeddedLView = lContainer[i];
|
|
12851
|
-
|
|
12852
|
-
ngDevMode && assertDefined(embeddedTView, 'TView must be allocated');
|
|
12853
|
-
if (viewAttachedToChangeDetector(embeddedLView)) {
|
|
12854
|
-
refreshView(embeddedTView, embeddedLView, embeddedTView.template, embeddedLView[CONTEXT]);
|
|
12855
|
-
}
|
|
12861
|
+
detectChangesInView(embeddedLView, mode);
|
|
12856
12862
|
}
|
|
12857
12863
|
}
|
|
12858
12864
|
}
|
|
@@ -12876,65 +12882,53 @@ function markTransplantedViewsForRefresh(lView) {
|
|
|
12876
12882
|
}
|
|
12877
12883
|
}
|
|
12878
12884
|
/**
|
|
12879
|
-
*
|
|
12885
|
+
* Detects changes in a component by entering the component view and processing its bindings,
|
|
12886
|
+
* queries, etc. if it is CheckAlways, OnPush and Dirty, etc.
|
|
12880
12887
|
*
|
|
12881
12888
|
* @param componentHostIdx Element index in LView[] (adjusted for HEADER_OFFSET)
|
|
12882
12889
|
*/
|
|
12883
|
-
function
|
|
12890
|
+
function detectChangesInComponent(hostLView, componentHostIdx, mode) {
|
|
12884
12891
|
ngDevMode && assertEqual(isCreationMode(hostLView), false, 'Should be run in update mode');
|
|
12885
12892
|
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
|
|
12886
|
-
|
|
12887
|
-
if (viewAttachedToChangeDetector(componentView)) {
|
|
12888
|
-
const tView = componentView[TVIEW];
|
|
12889
|
-
if (componentView[FLAGS] & (16 /* LViewFlags.CheckAlways */ | 64 /* LViewFlags.Dirty */)) {
|
|
12890
|
-
refreshView(tView, componentView, tView.template, componentView[CONTEXT]);
|
|
12891
|
-
}
|
|
12892
|
-
else if (componentView[DESCENDANT_VIEWS_TO_REFRESH] > 0) {
|
|
12893
|
-
// Only attached components that are CheckAlways or OnPush and dirty should be refreshed
|
|
12894
|
-
refreshContainsDirtyView(componentView);
|
|
12895
|
-
}
|
|
12896
|
-
}
|
|
12893
|
+
detectChangesInView(componentView, mode);
|
|
12897
12894
|
}
|
|
12898
12895
|
/**
|
|
12899
|
-
*
|
|
12900
|
-
*
|
|
12896
|
+
* Visits a view as part of change detection traversal.
|
|
12897
|
+
*
|
|
12898
|
+
* - If the view is detached, no additional traversal happens.
|
|
12899
|
+
*
|
|
12900
|
+
* The view is refreshed if:
|
|
12901
|
+
* - If the view is CheckAlways or Dirty and ChangeDetectionMode is `Global`
|
|
12902
|
+
* - If the view has the `RefreshTransplantedView` flag
|
|
12903
|
+
*
|
|
12904
|
+
* The view is not refreshed, but descendants are traversed in `ChangeDetectionMode.Targeted` if the
|
|
12905
|
+
* view has a non-zero TRANSPLANTED_VIEWS_TO_REFRESH counter.
|
|
12901
12906
|
*
|
|
12902
|
-
* @param lView The lView which contains descendant transplanted views that need to be refreshed.
|
|
12903
12907
|
*/
|
|
12904
|
-
function
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
const embeddedLView = lContainer[i];
|
|
12908
|
-
if (viewAttachedToChangeDetector(embeddedLView)) {
|
|
12909
|
-
if (embeddedLView[FLAGS] & 1024 /* LViewFlags.RefreshView */) {
|
|
12910
|
-
const embeddedTView = embeddedLView[TVIEW];
|
|
12911
|
-
ngDevMode && assertDefined(embeddedTView, 'TView must be allocated');
|
|
12912
|
-
refreshView(embeddedTView, embeddedLView, embeddedTView.template, embeddedLView[CONTEXT]);
|
|
12913
|
-
}
|
|
12914
|
-
else if (embeddedLView[DESCENDANT_VIEWS_TO_REFRESH] > 0) {
|
|
12915
|
-
refreshContainsDirtyView(embeddedLView);
|
|
12916
|
-
}
|
|
12917
|
-
}
|
|
12918
|
-
}
|
|
12908
|
+
function detectChangesInView(lView, mode) {
|
|
12909
|
+
if (!viewAttachedToChangeDetector(lView)) {
|
|
12910
|
+
return;
|
|
12919
12911
|
}
|
|
12920
12912
|
const tView = lView[TVIEW];
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12913
|
+
if ((lView[FLAGS] & (16 /* LViewFlags.CheckAlways */ | 64 /* LViewFlags.Dirty */) &&
|
|
12914
|
+
mode === 0 /* ChangeDetectionMode.Global */) ||
|
|
12915
|
+
lView[FLAGS] & 1024 /* LViewFlags.RefreshView */ ||
|
|
12916
|
+
mode === 2 /* ChangeDetectionMode.BugToForceRefreshAndIgnoreViewFlags */) {
|
|
12917
|
+
refreshView(tView, lView, tView.template, lView[CONTEXT]);
|
|
12918
|
+
}
|
|
12919
|
+
else if (lView[DESCENDANT_VIEWS_TO_REFRESH] > 0) {
|
|
12920
|
+
detectChangesInEmbeddedViews(lView, 1 /* ChangeDetectionMode.Targeted */);
|
|
12921
|
+
const tView = lView[TVIEW];
|
|
12922
|
+
const components = tView.components;
|
|
12923
|
+
if (components !== null) {
|
|
12924
|
+
detectChangesInChildComponents(lView, components, 1 /* ChangeDetectionMode.Targeted */);
|
|
12931
12925
|
}
|
|
12932
12926
|
}
|
|
12933
12927
|
}
|
|
12934
12928
|
/** Refreshes child components in the current view (update mode). */
|
|
12935
|
-
function
|
|
12929
|
+
function detectChangesInChildComponents(hostLView, components, mode) {
|
|
12936
12930
|
for (let i = 0; i < components.length; i++) {
|
|
12937
|
-
|
|
12931
|
+
detectChangesInComponent(hostLView, components[i], mode);
|
|
12938
12932
|
}
|
|
12939
12933
|
}
|
|
12940
12934
|
|
|
@@ -13334,8 +13328,12 @@ class ComponentFactory extends ComponentFactory$1 {
|
|
|
13334
13328
|
const hostRNode = rootSelectorOrNode ?
|
|
13335
13329
|
locateHostElement(hostRenderer, rootSelectorOrNode, this.componentDef.encapsulation, rootViewInjector) :
|
|
13336
13330
|
createElementNode(hostRenderer, elementName, getNamespace(elementName));
|
|
13337
|
-
|
|
13331
|
+
// Signal components use the granular "RefreshView" for change detection
|
|
13332
|
+
const signalFlags = (4096 /* LViewFlags.SignalView */ | 512 /* LViewFlags.IsRoot */);
|
|
13333
|
+
// Non-signal components use the traditional "CheckAlways or OnPush/Dirty" change detection
|
|
13334
|
+
const nonSignalFlags = this.componentDef.onPush ? 64 /* LViewFlags.Dirty */ | 512 /* LViewFlags.IsRoot */ :
|
|
13338
13335
|
16 /* LViewFlags.CheckAlways */ | 512 /* LViewFlags.IsRoot */;
|
|
13336
|
+
const rootFlags = this.componentDef.signals ? signalFlags : nonSignalFlags;
|
|
13339
13337
|
// Create the root view. Uses empty TView and ContentTemplate.
|
|
13340
13338
|
const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null, null);
|
|
13341
13339
|
const rootLView = createLView(null, rootTView, null, rootFlags, null, null, environment, hostRenderer, rootViewInjector, null, null);
|
|
@@ -13478,7 +13476,14 @@ function createRootComponentView(tNode, hostRNode, rootComponentDef, rootDirecti
|
|
|
13478
13476
|
hydrationInfo = retrieveHydrationInfo(hostRNode, rootView[INJECTOR$1]);
|
|
13479
13477
|
}
|
|
13480
13478
|
const viewRenderer = environment.rendererFactory.createRenderer(hostRNode, rootComponentDef);
|
|
13481
|
-
|
|
13479
|
+
let lViewFlags = 16 /* LViewFlags.CheckAlways */;
|
|
13480
|
+
if (rootComponentDef.signals) {
|
|
13481
|
+
lViewFlags = 4096 /* LViewFlags.SignalView */;
|
|
13482
|
+
}
|
|
13483
|
+
else if (rootComponentDef.onPush) {
|
|
13484
|
+
lViewFlags = 64 /* LViewFlags.Dirty */;
|
|
13485
|
+
}
|
|
13486
|
+
const componentView = createLView(rootView, getOrCreateComponentTView(rootComponentDef), null, lViewFlags, rootView[tNode.index], tNode, environment, viewRenderer, null, null, hydrationInfo);
|
|
13482
13487
|
if (tView.firstCreatePass) {
|
|
13483
13488
|
markAsComponentHost(tView, tNode, rootDirectives.length - 1);
|
|
13484
13489
|
}
|
|
@@ -23213,8 +23218,11 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
|
|
|
23213
23218
|
* @internal
|
|
23214
23219
|
*/
|
|
23215
23220
|
createEmbeddedViewImpl(context, injector, hydrationInfo) {
|
|
23221
|
+
// Embedded views follow the change detection strategy of the view they're declared in.
|
|
23222
|
+
const isSignalView = this._declarationLView[FLAGS] & 4096 /* LViewFlags.SignalView */;
|
|
23223
|
+
const viewFlags = isSignalView ? 4096 /* LViewFlags.SignalView */ : 16 /* LViewFlags.CheckAlways */;
|
|
23216
23224
|
const embeddedTView = this._declarationTContainer.tView;
|
|
23217
|
-
const embeddedLView = createLView(this._declarationLView, embeddedTView, context,
|
|
23225
|
+
const embeddedLView = createLView(this._declarationLView, embeddedTView, context, viewFlags, null, embeddedTView.declTNode, null, null, null, injector || null, hydrationInfo || null);
|
|
23218
23226
|
const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
|
|
23219
23227
|
ngDevMode && assertLContainer(declarationLContainer);
|
|
23220
23228
|
embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
|