@tantawowa/hosanna-ui 2.3.0 → 2.4.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/dist-manifest.json +69 -65
- package/package.json +1 -1
- package/src/hosanna-bridge-core/Promises.ts +1 -1
- package/src/hosanna-bridge-core/TimerService.ts +1 -1
- package/src/hosanna-bridge-core/decorators.ts +11 -3
- package/src/hosanna-bridge-lib/FocusManager.ts +1 -1
- package/src/hosanna-bridge-lib/PerfettoUtil.ts +1 -1
- package/src/hosanna-bridge-lib/SystemMessageManager.ts +1 -1
- package/src/hosanna-bridge-lib/TextToSpeechManager.ts +1 -1
- package/src/hosanna-bridge-lib/decorators.ts +1 -0
- package/src/hosanna-bridge-targets/common/device/AppPerformanceManager.ts +2 -2
- package/src/hosanna-bridge-targets/common/device/DeviceRegistry.ts +1 -1
- package/src/hosanna-bridge-targets/common/device/HosannaDevice.ts +3 -3
- package/src/hosanna-list/BaseCollectionViewLayout.ts +4 -4
- package/src/hosanna-list/BaseCollectionViewRow.ts +8 -0
- package/src/hosanna-list/CollectionView.ts +24 -7
- package/src/hosanna-list/CollectionViewAPI.ts +2 -0
- package/src/hosanna-list/CollectionViewDSLManager.ts +1 -1
- package/src/hosanna-list/CollectionViewDataSource.ts +2 -2
- package/src/hosanna-list/CollectionViewFocusManager.ts +1 -1
- package/src/hosanna-list/CustomViewRow.ts +2 -2
- package/src/hosanna-list/CustomViewRowLayout.ts +1 -1
- package/src/hosanna-list/DynamicCell.ts +16 -6
- package/src/hosanna-list/EPGProgramLayout.ts +2 -2
- package/src/hosanna-list/EPGView.ts +1 -1
- package/src/hosanna-list/GridRowLayout.ts +1 -1
- package/src/hosanna-list/HorizontalRow.ts +14 -1
- package/src/hosanna-list/HorizontalRowLayout.ts +38 -2
- package/src/hosanna-list/ListRowLayout.ts +1 -1
- package/src/hosanna-list/focusStrategies/HorizontalHybridFocusAnimationStrategy.ts +16 -2
- package/src/hosanna-ui/async/AbstractAsyncHandler.ts +2 -2
- package/src/hosanna-ui/async/AsyncCommandHandler.ts +1 -1
- package/src/hosanna-ui/async/AsyncManager.ts +2 -2
- package/src/hosanna-ui/async/AsyncTaskMessageLoop.ts +2 -2
- package/src/hosanna-ui/lib/BaseApp.ts +1 -9
- package/src/hosanna-ui/lib/FragmentFocusStyle.ts +151 -0
- package/src/hosanna-ui/lib/HosannaDeviceUpdateManager.ts +6 -6
- package/src/hosanna-ui/lib/MeasurementUtils.ts +2 -2
- package/src/hosanna-ui/lib/animation.ts +1 -1
- package/src/hosanna-ui/lib/debugger/RemoteDebugClient.ts +1 -1
- package/src/hosanna-ui/lib/images/ImageCacher.ts +1 -1
- package/src/hosanna-ui/lib/orientation/OrientationController.ts +1 -1
- package/src/hosanna-ui/lib/rive/RiveManager.ts +1 -1
- package/src/hosanna-ui/lib/test-utils.ts +44 -3
- package/src/hosanna-ui/targets/common/app/AppInitializer.ts +2 -0
- package/src/hosanna-ui/views/aggregate-views/AggregateViewTransition.ts +1 -1
- package/src/hosanna-ui/views/aggregate-views/FadeTransition.ts +1 -1
- package/src/hosanna-ui/views/aggregate-views/NavController.ts +4 -0
- package/src/hosanna-ui/views/controls/Button.ts +1 -1
- package/src/hosanna-ui/views/controls/FragmentView.ts +1 -1
- package/src/hosanna-ui/views/dialogs/DialogManager.ts +1 -1
- package/src/hosanna-ui/views/groups/Mask.ts +1 -1
- package/src/hosanna-ui/views/groups/SafeArea.ts +1 -1
- package/src/hosanna-ui/views/lib/AppConfig.ts +22 -0
- package/src/hosanna-ui/views/lib/BaseView.ts +7 -16
- package/src/hosanna-ui/views/lib/SharedVideoPlayerState.ts +1 -1
- package/src/hosanna-ui/views/lib/ViewBuilder.ts +1 -1
- package/src/hosanna-ui/views/lib/ViewFragmentProvider.ts +36 -13
- package/src/hosanna-ui/views/primitives/AnimatedPoster.ts +1 -1
- package/src/hosanna-ui/views/primitives/Label.ts +2 -2
- package/src/hosanna-ui/views/primitives/MultiStyleLabel.ts +1 -1
- package/src/hosanna-ui/views/primitives/RiveAnimation.ts +1 -1
- package/src/hosanna-ui/views/primitives/SimpleLabel.ts +2 -2
- package/src/hosanna-ui/views/primitives/VideoPlayer.ts +1 -1
- package/src/hosanna-ui/views/screens/SpringboardScreen.ts +1 -1
- package/src/hosanna-ui/views/toasts/ToastManager.ts +2 -2
|
@@ -144,11 +144,11 @@ export class BaseCollectionViewLayout {
|
|
|
144
144
|
protected lastConfiguredVisibleRangeKey = '';
|
|
145
145
|
|
|
146
146
|
/** Injected instance pool for cell reuse. */
|
|
147
|
-
@inject() instancePool!: IInstancePool;
|
|
147
|
+
@inject({ eager: true }) instancePool!: IInstancePool;
|
|
148
148
|
/** Injected node pool for node reuse. */
|
|
149
|
-
@inject() nodePool!: INodePool;
|
|
149
|
+
@inject({ eager: true }) nodePool!: INodePool;
|
|
150
150
|
/** Injected font manager for font lookups. */
|
|
151
|
-
@inject() fontManager!: FontManager;
|
|
151
|
+
@inject({ eager: true }) fontManager!: FontManager;
|
|
152
152
|
|
|
153
153
|
/** The row this layout manages. */
|
|
154
154
|
row!: ResolvedHorizontalReadingDirectionRow;
|
|
@@ -199,7 +199,7 @@ export class BaseCollectionViewLayout {
|
|
|
199
199
|
/** The callback to invoke when the row is released. */
|
|
200
200
|
onReleaseFinish: ((layout: BaseCollectionViewLayout) => void) | undefined = undefined;
|
|
201
201
|
/** Injected view fragment provider for component-based headers. */
|
|
202
|
-
@inject() viewFragmentProvider!: ViewFragmentProvider;
|
|
202
|
+
@inject({ eager: true }) viewFragmentProvider!: ViewFragmentProvider;
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* Constructs a new BaseCollectionViewLayout.
|
|
@@ -666,6 +666,14 @@ export class BaseCollectionViewRow<T extends BaseCollectionViewLayout> implement
|
|
|
666
666
|
return this.getRowTargetItemIndexForVerticalSingleMove(direction);
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
+
get usesLeadingEdgeItemOnEntry(): boolean {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
resolveVerticalEntryItemIndex(defaultIndex: number): number {
|
|
674
|
+
return defaultIndex;
|
|
675
|
+
}
|
|
676
|
+
|
|
669
677
|
/**
|
|
670
678
|
* Gets the item index based on the focus strategy when moving vertically.
|
|
671
679
|
* @param direction -1 for up, 1 for down
|
|
@@ -702,15 +702,15 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
|
|
|
702
702
|
|
|
703
703
|
|
|
704
704
|
/** Injected instance pool for row reuse. */
|
|
705
|
-
@inject() instancePool!: InstancePool;
|
|
705
|
+
@inject({ eager: true }) instancePool!: InstancePool;
|
|
706
706
|
/** Injected timer service for tick events. */
|
|
707
|
-
@inject() protected timerService!: TimerService;
|
|
707
|
+
@inject({ eager: true }) protected timerService!: TimerService;
|
|
708
708
|
/** Injected collection view DSL manager. */
|
|
709
|
-
@inject() collectionViewDSLManager!: ICollectionViewDSLManager;
|
|
709
|
+
@inject({ eager: true }) collectionViewDSLManager!: ICollectionViewDSLManager;
|
|
710
710
|
/** Injected row callbacks provider. */
|
|
711
|
-
@inject() rowCallbacksProvider!: IRowCallbacksProvider;
|
|
711
|
+
@inject({ eager: true }) rowCallbacksProvider!: IRowCallbacksProvider;
|
|
712
712
|
/** Native display metrics used by the opt-in safe-focus policy. */
|
|
713
|
-
@inject('hosannaDevice') private safeAreaDevice!: IHosannaDevice;
|
|
713
|
+
@inject('hosannaDevice', { eager: true }) private safeAreaDevice!: IHosannaDevice;
|
|
714
714
|
/*******************************************************************
|
|
715
715
|
* Rendering
|
|
716
716
|
*******************************************************************/
|
|
@@ -999,6 +999,10 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
|
|
|
999
999
|
: 0;
|
|
1000
1000
|
this.jumpToRow(targetRow, targetItem, true);
|
|
1001
1001
|
} else {
|
|
1002
|
+
// The replacement rows may have a different screenPosition. Use their
|
|
1003
|
+
// laid-out scroll origin for focus geometry before rendering the indicator.
|
|
1004
|
+
this.cachedFocusedRowVirtualY = this.virtualY;
|
|
1005
|
+
this.cachedNextRowVirtualY = this.virtualY;
|
|
1002
1006
|
// clearExistingRows() reset first/lastVisibleRow to 0, so renderVisibleRows()
|
|
1003
1007
|
// would paint only that default [0..0] range for the new data until the next
|
|
1004
1008
|
// scroll tick recomputed visibility. refreshVisibleRows() runs the
|
|
@@ -2212,7 +2216,7 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
|
|
|
2212
2216
|
this.startAnimatingRowToItemIndex(targetItemIndex, scrollSpeedIndex > 0, targetRowIndex);
|
|
2213
2217
|
}
|
|
2214
2218
|
|
|
2215
|
-
this.setNextFocusTrackingFieldsWhenLeavingRow();
|
|
2219
|
+
this.setNextFocusTrackingFieldsWhenLeavingRow(isLongPressEnd);
|
|
2216
2220
|
|
|
2217
2221
|
// When ending longpress vertical scroll: continue the interrupted animation using remaining time
|
|
2218
2222
|
// so the first frame interpolates to current position without jumping.
|
|
@@ -3710,12 +3714,13 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
|
|
|
3710
3714
|
*
|
|
3711
3715
|
* @private
|
|
3712
3716
|
*/
|
|
3713
|
-
private setNextFocusTrackingFieldsWhenLeavingRow() {
|
|
3717
|
+
private setNextFocusTrackingFieldsWhenLeavingRow(isLongPressEnd = false) {
|
|
3714
3718
|
if (this.rows.length === 0) {
|
|
3715
3719
|
console.warn('cannot track: no rows');
|
|
3716
3720
|
return;
|
|
3717
3721
|
}
|
|
3718
3722
|
|
|
3723
|
+
const previousNextIndices = this.nextItemIndices;
|
|
3719
3724
|
this.determineNextItemIndices();
|
|
3720
3725
|
|
|
3721
3726
|
console.info('next item indices', this.nextItemIndices, this.focusedIndices);
|
|
@@ -3731,6 +3736,18 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
|
|
|
3731
3736
|
return;
|
|
3732
3737
|
}
|
|
3733
3738
|
|
|
3739
|
+
// Programmatic scrollToRow owns its explicit destination and blocks D-pad input.
|
|
3740
|
+
if (!this.blockInputEvents && this.requestedDirectionToMove === Direction.Vertical
|
|
3741
|
+
&& nextRow.index !== this.focusedIndices[0] && nextRow.usesLeadingEdgeItemOnEntry) {
|
|
3742
|
+
const itemIndex = isLongPressEnd && previousNextIndices[0] === nextRow.index
|
|
3743
|
+
? previousNextIndices[1]
|
|
3744
|
+
: nextRow.resolveVerticalEntryItemIndex(this.nextItemIndices[1]);
|
|
3745
|
+
this.nextItemIndices[1] = itemIndex;
|
|
3746
|
+
if (this.targetIndices[0] === nextRow.index) {
|
|
3747
|
+
this.targetIndices[1] = itemIndex;
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3734
3751
|
// This shoulb be always 1, but we need to keep the logic for the future
|
|
3735
3752
|
// const rowsToMove = this.getVirtualRowsCountToMove(this.focusedIndices, this.nextItemIndices);
|
|
3736
3753
|
const rowsToMove = 1;
|
|
@@ -53,6 +53,8 @@ export enum CollectionViewRowFocusStrategy {
|
|
|
53
53
|
FocusOnPreviousItem = 'focusOnPreviousItem',
|
|
54
54
|
FocusOnClosestItem = 'focusOnClosestItem',
|
|
55
55
|
FocusOnSelectedItem = 'focusOnSelectedItem',
|
|
56
|
+
/** On vertical D-pad entry into a horizontal Hybrid row, focus its first fully visible card in reading order. */
|
|
57
|
+
FocusOnLeadingEdgeItem = 'focusOnLeadingEdgeItem',
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
export interface CollectionViewItemBounds {
|
|
@@ -24,7 +24,7 @@ export class CollectionViewDSLManager implements ICollectionViewDSLManager {
|
|
|
24
24
|
|
|
25
25
|
protected keyEventTriggersWasHandled: boolean = false;
|
|
26
26
|
|
|
27
|
-
@inject() dataSourceRowLoadingManager!: DataSourceRowLoadingManager;
|
|
27
|
+
@inject({ eager: true }) dataSourceRowLoadingManager!: DataSourceRowLoadingManager;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Handles item selection events and executes DSL triggers
|
|
@@ -36,10 +36,10 @@ export class CollectionViewDataSource {
|
|
|
36
36
|
private loadingItemsCount = 6;
|
|
37
37
|
|
|
38
38
|
/** Injected style registry for resolving row styles. */
|
|
39
|
-
@inject() private appConfig!: AppConfig;
|
|
39
|
+
@inject({ eager: true }) private appConfig!: AppConfig;
|
|
40
40
|
|
|
41
41
|
/** Injected view manager for error reporting. */
|
|
42
|
-
@inject() private viewManager!: IViewManager;
|
|
42
|
+
@inject({ eager: true }) private viewManager!: IViewManager;
|
|
43
43
|
|
|
44
44
|
/** Default style key for error rows. */
|
|
45
45
|
private defaultErrorRowStyle = 'rows.regularError';
|
|
@@ -52,7 +52,7 @@ export class CollectionViewFocusManager implements ICollectionViewFocusManager,
|
|
|
52
52
|
/**
|
|
53
53
|
* Injects the text-to-speech manager for providing audio feedback on focus changes.
|
|
54
54
|
*/
|
|
55
|
-
@inject() private textToSpeechManager!: ITextToSpeechManager;
|
|
55
|
+
@inject({ eager: true }) private textToSpeechManager!: ITextToSpeechManager;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* The focus rectangle node used to visually indicate the focused item.
|
|
@@ -29,10 +29,10 @@ export class CustomViewRow extends BaseCollectionViewRow<CustomViewRowLayout> {
|
|
|
29
29
|
/**
|
|
30
30
|
* Injected instance pool for managing reusable views.
|
|
31
31
|
*/
|
|
32
|
-
@inject() instancePool!: IInstancePool;
|
|
32
|
+
@inject({ eager: true }) instancePool!: IInstancePool;
|
|
33
33
|
|
|
34
34
|
/** Global focus owner used to hand focus away before releasing a mounted custom view. */
|
|
35
|
-
@inject('focusManager') private appFocusManager!: IFocusManager;
|
|
35
|
+
@inject('focusManager', { eager: true }) private appFocusManager!: IFocusManager;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Creates the layout for this row.
|
|
@@ -19,7 +19,7 @@ export class CustomViewRowLayout extends BaseCollectionViewLayout {
|
|
|
19
19
|
/**
|
|
20
20
|
* Injected node pool for managing reusable nodes.
|
|
21
21
|
*/
|
|
22
|
-
@inject() nodePool!: INodePool;
|
|
22
|
+
@inject({ eager: true }) nodePool!: INodePool;
|
|
23
23
|
|
|
24
24
|
override get numberOfItems(): number {
|
|
25
25
|
//TODO - change this once we have a proper way to handle custom view items
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { applyFragmentFocusStyle } from '@hs-src/hosanna-ui/lib/FragmentFocusStyle';
|
|
1
2
|
import { inject } from '@hs-src/hosanna-bridge-core/decorators';
|
|
2
3
|
import { BaseCell } from './BaseCell';
|
|
3
4
|
import { IViewFragmentProvider } from '@hs-src/hosanna-ui/views/lib/ViewFragmentProvider';
|
|
4
|
-
import { IAppConfig, IViewFragment, IViewFragmentStyle, ViewFragmentCallbackHandler, ViewFragmentCallbackType, ViewFragmentFocusPercentCallbackHandler } from '@hs-src/hosanna-ui/views/lib/AppConfig';
|
|
5
|
+
import { IAppConfig, isFragmentStyleStale, IViewFragment, IViewFragmentStyle, ViewFragmentCallbackHandler, ViewFragmentCallbackType, ViewFragmentFocusPercentCallbackHandler } from '@hs-src/hosanna-ui/views/lib/AppConfig';
|
|
5
6
|
import { applyDataMap } from '@hs-src/hosanna-ui/lib/FragmentUtils';
|
|
6
7
|
import { scrollJankChildCount, scrollJankDuration, scrollJankLog, scrollJankNodeId, scrollJankNow } from '@hs-src/hosanna-ui/lib/ScrollJankLogger';
|
|
7
8
|
import {
|
|
@@ -32,9 +33,9 @@ export class DynamicCell extends BaseCell {
|
|
|
32
33
|
/**
|
|
33
34
|
* Injected provider for managing view fragments.
|
|
34
35
|
*/
|
|
35
|
-
@inject() private viewFragmentProvider!: IViewFragmentProvider;
|
|
36
|
+
@inject({ eager: true }) private viewFragmentProvider!: IViewFragmentProvider;
|
|
36
37
|
|
|
37
|
-
@inject() private appConfig!: IAppConfig;
|
|
38
|
+
@inject({ eager: true }) private appConfig!: IAppConfig;
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* The current view fragment associated with this cell.
|
|
@@ -96,8 +97,7 @@ export class DynamicCell extends BaseCell {
|
|
|
96
97
|
// The second part of the condition checks if the row's container ID matches the view fragment's parent ID.
|
|
97
98
|
// The container id can change if the collection view is re-created
|
|
98
99
|
if (this.currentStyle !== styleKey || this.row.container.id !== this.viewFragment?.view?.getParent()?.id
|
|
99
|
-
|| (this.viewFragment
|
|
100
|
-
&& this.viewFragment.styleLayoutRevision !== this.appConfig.getStyleLayoutRevision())) {
|
|
100
|
+
|| (this.viewFragment !== undefined && isFragmentStyleStale(this.viewFragment, this.appConfig))) {
|
|
101
101
|
if (this.viewFragment) {
|
|
102
102
|
// Call onUnmount callbacks before removing
|
|
103
103
|
this.invokeCallbacks(ViewFragmentCallbackType.OnUnmount, this.viewFragment);
|
|
@@ -128,7 +128,14 @@ export class DynamicCell extends BaseCell {
|
|
|
128
128
|
if (this.viewFragment.viewStatus !== this.viewStatus) {
|
|
129
129
|
this.applyViewStatus(this.viewStatus);
|
|
130
130
|
} else {
|
|
131
|
-
|
|
131
|
+
// The item can change while the status stays selected, disabled, or in footprint.
|
|
132
|
+
// Re-resolve data-dependent status fields against the new item before laying it out.
|
|
133
|
+
let computed;
|
|
134
|
+
if (this.viewFragment.focusStyleTracks && this.viewFragment.dataMap?.computed && this.viewStatus !== ViewStatus.Normal) {
|
|
135
|
+
computed = applyFragmentComputed(this.viewFragment, this.item, this.getFragmentComputedContext(this.viewStatus));
|
|
136
|
+
this.viewFragmentProvider.applyViewStatus(this.viewFragment, this.viewStatus);
|
|
137
|
+
}
|
|
138
|
+
this.applyComputedAndConstraints(fragmentStyle, this.viewStatus, computed);
|
|
132
139
|
this.refreshFragmentAccessibility();
|
|
133
140
|
}
|
|
134
141
|
this.invokeCallbacks(ViewFragmentCallbackType.OnDataChange, this.viewFragment);
|
|
@@ -467,6 +474,9 @@ export class DynamicCell extends BaseCell {
|
|
|
467
474
|
this.viewFragment.rowFocusPercent = undefined;
|
|
468
475
|
}
|
|
469
476
|
}
|
|
477
|
+
if (this.viewFragment?.focusStyleTracks) {
|
|
478
|
+
applyFragmentFocusStyle(this.viewFragment, 0);
|
|
479
|
+
}
|
|
470
480
|
}
|
|
471
481
|
|
|
472
482
|
override onWillRelease(): void {
|
|
@@ -15,8 +15,8 @@ import { applyFragmentConstraints } from '@hs-src/hosanna-ui/lib/FragmentConstra
|
|
|
15
15
|
|
|
16
16
|
export class EPGProgramLayout extends BaseCollectionViewLayout {
|
|
17
17
|
|
|
18
|
-
@inject() fontManager!: FontManager;
|
|
19
|
-
@inject() appConfig!: AppConfig;
|
|
18
|
+
@inject({ eager: true }) fontManager!: FontManager;
|
|
19
|
+
@inject({ eager: true }) appConfig!: AppConfig;
|
|
20
20
|
|
|
21
21
|
enabled = true;
|
|
22
22
|
|
|
@@ -28,7 +28,7 @@ import { HorizontalRow } from './HorizontalRow';
|
|
|
28
28
|
@view('EPGView')
|
|
29
29
|
export class EPGViewView extends CollectionViewView implements IEPGView {
|
|
30
30
|
|
|
31
|
-
@inject() viewFragmentProvider!: IViewFragmentProvider;
|
|
31
|
+
@inject({ eager: true }) viewFragmentProvider!: IViewFragmentProvider;
|
|
32
32
|
|
|
33
33
|
// renderOnlyOnscreenRows is enabled ONLY around the per-frame timeline-scroll render (see
|
|
34
34
|
// onTimelineXChanged), not for reload/jump/vertical renders. Skipping warmed-up off-screen rows
|
|
@@ -23,7 +23,7 @@ export class GridRowLayout extends BaseCollectionViewLayout {
|
|
|
23
23
|
/**
|
|
24
24
|
* Injected node pool for managing reusable nodes.
|
|
25
25
|
*/
|
|
26
|
-
@inject() nodePool!: INodePool;
|
|
26
|
+
@inject({ eager: true }) nodePool!: INodePool;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* The width of the viewport for visible rows.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseCollectionViewRow } from './BaseCollectionViewRow';
|
|
2
2
|
import { HorizontalRowLayout } from './HorizontalRowLayout';
|
|
3
|
-
import { CollectionViewDataSourceType, ICollectionView, ICollectionViewDataSourceRow, RowCallbackType } from './CollectionViewAPI';
|
|
3
|
+
import { CollectionViewDataSourceType, CollectionViewRowFocusStrategy, ICollectionView, ICollectionViewDataSourceRow, RowCallbackType, RowFocusAnimationStrategy } from './CollectionViewAPI';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `HorizontalRow` is a specialized implementation of `BaseCollectionViewRow`
|
|
@@ -79,6 +79,19 @@ export class HorizontalRow extends BaseCollectionViewRow<HorizontalRowLayout> {
|
|
|
79
79
|
return this.layout.getCellWidth(index);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
override get usesLeadingEdgeItemOnEntry(): boolean {
|
|
83
|
+
return this.focusStrategy === CollectionViewRowFocusStrategy.FocusOnLeadingEdgeItem
|
|
84
|
+
&& this.focusSettings.horizAnimSettings === RowFocusAnimationStrategy.Hybrid;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
override resolveVerticalEntryItemIndex(defaultIndex: number): number {
|
|
88
|
+
if (!this.usesLeadingEdgeItemOnEntry) {
|
|
89
|
+
return defaultIndex;
|
|
90
|
+
}
|
|
91
|
+
const index = this.layout.getFirstFullyVisibleItemIndex();
|
|
92
|
+
return index === -1 ? defaultIndex : index;
|
|
93
|
+
}
|
|
94
|
+
|
|
82
95
|
override canHandleHorizontalPointerScroll(): boolean {
|
|
83
96
|
return true;
|
|
84
97
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { inject } from '@hs-src/hosanna-bridge-core/decorators';
|
|
2
2
|
import { INodePool } from '@hs-src/hosanna-ui/lib/NodePool';
|
|
3
3
|
import { BaseCollectionViewLayout } from './BaseCollectionViewLayout';
|
|
4
|
-
import { CollectionViewItemBounds, RenderEvent } from './CollectionViewAPI';
|
|
4
|
+
import { CollectionViewItemBounds, ILoadingItem, RenderEvent } from './CollectionViewAPI';
|
|
5
5
|
import { scrollJankDuration, scrollJankLog, scrollJankNow } from '@hs-src/hosanna-ui/lib/ScrollJankLogger';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -18,7 +18,7 @@ export class HorizontalRowLayout extends BaseCollectionViewLayout {
|
|
|
18
18
|
/**
|
|
19
19
|
* Injected node pool for managing reusable nodes.
|
|
20
20
|
*/
|
|
21
|
-
@inject() nodePool!: INodePool;
|
|
21
|
+
@inject({ eager: true }) nodePool!: INodePool;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Array storing individual cell widths when isVariableWidth is true.
|
|
@@ -299,6 +299,42 @@ export class HorizontalRowLayout extends BaseCollectionViewLayout {
|
|
|
299
299
|
return itemStartX + (cellWidth / 2);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
+
/** Finds the first card inside the focus margins using the retained scroll offset. */
|
|
303
|
+
getFirstFullyVisibleItemIndex(): number {
|
|
304
|
+
const row = this.row;
|
|
305
|
+
const left = (row.getFocusAreaLeft?.() ?? row.xOffset) + this.virtualPosition - row.xOffset;
|
|
306
|
+
const right = (row.getFocusAreaRight?.() ?? row.floatingFocusAreaWidth) + this.virtualPosition - row.xOffset;
|
|
307
|
+
const items = row.content.items;
|
|
308
|
+
const fromRight = row.horizontalDirectionMultiplier === -1;
|
|
309
|
+
|
|
310
|
+
// Find the first logical card whose leading edge is inside the viewport.
|
|
311
|
+
let first = 0;
|
|
312
|
+
let endIndex = items.length;
|
|
313
|
+
while (first < endIndex) {
|
|
314
|
+
const index = Math.floor((first + endIndex) / 2);
|
|
315
|
+
const x = this.getHorizontalVirtualPositionForIndex(index);
|
|
316
|
+
const clippedAtLeadingEdge = fromRight ? x + this.getCellWidth(index) > right : x < left;
|
|
317
|
+
if (clippedAtLeadingEdge) {
|
|
318
|
+
first = index + 1;
|
|
319
|
+
} else {
|
|
320
|
+
endIndex = index;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
for (let index = first; index < items.length; index++) {
|
|
325
|
+
const x = this.getHorizontalVirtualPositionForIndex(index);
|
|
326
|
+
const width = this.getCellWidth(index);
|
|
327
|
+
if (fromRight ? x < left : x + width > right) {
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
const item = items[index] as ILoadingItem | undefined;
|
|
331
|
+
if (width > 0 && item && !item.isLoadingItem) {
|
|
332
|
+
return index;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return -1;
|
|
336
|
+
}
|
|
337
|
+
|
|
302
338
|
public override getItemBoundsForIndex(index: number): CollectionViewItemBounds | undefined {
|
|
303
339
|
if (index < 0 || index >= this.numberOfItems) {
|
|
304
340
|
return undefined;
|
|
@@ -23,7 +23,7 @@ export class ListRowLayout extends BaseCollectionViewLayout {
|
|
|
23
23
|
/**
|
|
24
24
|
* Injected node pool for managing reusable nodes.
|
|
25
25
|
*/
|
|
26
|
-
@inject() nodePool!: INodePool;
|
|
26
|
+
@inject({ eager: true }) nodePool!: INodePool;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* The vertical offset for rendering rows.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RenderEvent } from '../CollectionViewAPI';
|
|
1
|
+
import { ILoadingItem, RenderEvent } from '../CollectionViewAPI';
|
|
2
2
|
import { HorizontalBaseFocusAnimationStrategy } from './HorizontalBaseFocusAnimationStrategy';
|
|
3
3
|
|
|
4
4
|
export class HorizontalHybridFocusAnimationStrategy extends HorizontalBaseFocusAnimationStrategy {
|
|
@@ -14,6 +14,9 @@ export class HorizontalHybridFocusAnimationStrategy extends HorizontalBaseFocusA
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
isNextItemAtTargetPosition(targetItemIndex: number): boolean {
|
|
17
|
+
if (this.row.usesLeadingEdgeItemOnEntry) {
|
|
18
|
+
return this.getTargetVirtualPosition(targetItemIndex) === this.rowLayout.virtualPosition;
|
|
19
|
+
}
|
|
17
20
|
if (this.row.direction === 1) {
|
|
18
21
|
const lastItemIndex = this.rowLayout.numberOfItems - 1;
|
|
19
22
|
return this.rowLayout.isIndexInModifiedFloatingFocusAreaAtPosition(lastItemIndex, this.rowLayout.virtualPosition);
|
|
@@ -49,6 +52,15 @@ export class HorizontalHybridFocusAnimationStrategy extends HorizontalBaseFocusA
|
|
|
49
52
|
return 0; // Index out of bounds
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
// A vertical entry can focus a card away from its normal horizontal anchor.
|
|
56
|
+
if (this.row.usesLeadingEdgeItemOnEntry && !this.row.isAnimating) {
|
|
57
|
+
const item = this.row.content.items[index] as ILoadingItem | undefined;
|
|
58
|
+
if (item && !item.isLoadingItem && rowLayout.getCellWidth(index) > 0
|
|
59
|
+
&& rowLayout.isIndexInModifiedFloatingFocusAreaAtPosition(index, rowLayout.virtualPosition)) {
|
|
60
|
+
return this.getScreenXForIndexAtVirtualPosition(index, rowLayout.virtualPosition);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
52
64
|
const trailingVirtualPosition = this.getTrailingVirtualPositionLimit();
|
|
53
65
|
const targetVirtualPosition = this.getTargetVirtualPosition(index, trailingVirtualPosition);
|
|
54
66
|
return this.getScreenXForIndexAtVirtualPosition(index, targetVirtualPosition);
|
|
@@ -65,7 +77,9 @@ export class HorizontalHybridFocusAnimationStrategy extends HorizontalBaseFocusA
|
|
|
65
77
|
configureForNextItem(event: RenderEvent, nextItemIndex: number): void {
|
|
66
78
|
this.cachedTrailingVirtualPosition = this.getTrailingVirtualPositionLimit();
|
|
67
79
|
this.nextItemPosition = this.getVirtualPositionForIndexAtLeadingFocusEdge(nextItemIndex);
|
|
68
|
-
this.localStartItemPosition = this.
|
|
80
|
+
this.localStartItemPosition = this.row.usesLeadingEdgeItemOnEntry
|
|
81
|
+
? this.rowLayout.virtualPosition
|
|
82
|
+
: this.getVirtualPositionForIndexAtLeadingFocusEdge(this.localStartIndex);
|
|
69
83
|
this.isSingleMove = !this.row.isFastScroll;
|
|
70
84
|
}
|
|
71
85
|
|
|
@@ -55,10 +55,10 @@ export function command(commandName: string) {
|
|
|
55
55
|
*/
|
|
56
56
|
export class AbstractAsyncHandler {
|
|
57
57
|
/** Injected HTTP fetch utility for async operations. */
|
|
58
|
-
@inject() hsFetch!: HsFetch;
|
|
58
|
+
@inject({ eager: true }) hsFetch!: HsFetch;
|
|
59
59
|
|
|
60
60
|
/** Injected developer utilities for debugging and mock responses. */
|
|
61
|
-
@inject() developerUtils!: IDeveloperUtils;
|
|
61
|
+
@inject({ eager: true }) developerUtils!: IDeveloperUtils;
|
|
62
62
|
|
|
63
63
|
/** Reference to the async manager for command completion and cancellation. */
|
|
64
64
|
manager: IAsyncManager;
|
|
@@ -18,7 +18,7 @@ import type { IHosannaCurrentDesignResolution } from '../lib/HosannaDeviceUpdate
|
|
|
18
18
|
export class AsyncCommandHandler implements IAsyncCommandHandler, ITickable {
|
|
19
19
|
|
|
20
20
|
/** Injected timer service for scheduling ticks. */
|
|
21
|
-
@inject() protected timerService!: TimerService;
|
|
21
|
+
@inject({ eager: true }) protected timerService!: TimerService;
|
|
22
22
|
|
|
23
23
|
/** Map of command queues by task pool ID. */
|
|
24
24
|
private commandQueuesByTaskId: Map<string, AsyncCommandQueue> = new Map();
|
|
@@ -62,10 +62,10 @@ export function configureHosannaForAsyncTask(top: ISGNNode) {
|
|
|
62
62
|
*/
|
|
63
63
|
export class AsyncManager implements IAsyncManager {
|
|
64
64
|
/** Injected system service for ticking system-level operations. */
|
|
65
|
-
@inject() private systemService!: ISystemService;
|
|
65
|
+
@inject({ eager: true }) private systemService!: ISystemService;
|
|
66
66
|
|
|
67
67
|
/** Injected timer service for ticking timer-based operations. */
|
|
68
|
-
@inject() private timerService!: TimerService;
|
|
68
|
+
@inject({ eager: true }) private timerService!: TimerService;
|
|
69
69
|
|
|
70
70
|
/** Queue for managing async events. */
|
|
71
71
|
private eventQueue = new AsyncEventQueue();
|
|
@@ -19,8 +19,8 @@ let nextLoopId = 0;
|
|
|
19
19
|
* must arrive through the private port while Roku's command dispatcher is busy.
|
|
20
20
|
*/
|
|
21
21
|
export class AsyncTaskMessageLoop<T = unknown> implements ITickable {
|
|
22
|
-
@inject() private systemService!: ISystemService;
|
|
23
|
-
@inject() private timerService!: TimerService;
|
|
22
|
+
@inject({ eager: true }) private systemService!: ISystemService;
|
|
23
|
+
@inject({ eager: true }) private timerService!: TimerService;
|
|
24
24
|
|
|
25
25
|
readonly id: string;
|
|
26
26
|
private completion = new HsPromise<void>();
|
|
@@ -496,15 +496,7 @@ export class BaseApp extends BaseView<ViewState> implements IObserver {
|
|
|
496
496
|
this.prepareScene();
|
|
497
497
|
this.observeSceneDesignResolutionChanges();
|
|
498
498
|
this.configureIoC();
|
|
499
|
-
|
|
500
|
-
// On emulated web, we need to call it directly
|
|
501
|
-
const platform = AppUtils.getPlatform();
|
|
502
|
-
if (platform === PlatformType.Roku) {
|
|
503
|
-
hs_native_roku('m.assignBaseIOCServices()');
|
|
504
|
-
} else {
|
|
505
|
-
// Emulated web: call directly since hs_native_roku is a no-op
|
|
506
|
-
this.assignBaseIOCServices();
|
|
507
|
-
}
|
|
499
|
+
this.assignBaseIOCServices();
|
|
508
500
|
this.initializeViewNotifications();
|
|
509
501
|
this.beforeLaunch();
|
|
510
502
|
// CRITICAL: Resolve IoC dependencies BEFORE creating views
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { blendColors, colorToHex, colorToRgba } from '@hs-src/hosanna-bridge-core/color';
|
|
2
|
+
import type { ISGNNode } from '@hs-src/hosanna-bridge-targets/common/sg-api';
|
|
3
|
+
import type { JsonData } from '../async/AsyncApi';
|
|
4
|
+
import type { IFragmentFocusAnimation, IFragmentStyle, IViewFragment } from '../views/lib/AppConfig';
|
|
5
|
+
import { ViewStatus } from '../hosanna-api';
|
|
6
|
+
import { interpolatePoint, isHexColor } from './animation-utils';
|
|
7
|
+
|
|
8
|
+
type Endpoint = number | number[] | string;
|
|
9
|
+
|
|
10
|
+
enum FieldKind { Scalar, Vector, Color }
|
|
11
|
+
|
|
12
|
+
interface EndpointPair {
|
|
13
|
+
start: Endpoint;
|
|
14
|
+
target: Endpoint;
|
|
15
|
+
startColor?: number;
|
|
16
|
+
targetColor?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface FragmentFocusStyleTrack {
|
|
20
|
+
progress: IFragmentFocusAnimation['progress'];
|
|
21
|
+
kind: FieldKind;
|
|
22
|
+
node: ISGNNode;
|
|
23
|
+
field: string;
|
|
24
|
+
normal: EndpointPair;
|
|
25
|
+
selected?: EndpointPair;
|
|
26
|
+
focusSelected?: EndpointPair;
|
|
27
|
+
focusFootprint?: EndpointPair;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FragmentFocusStyleTracks {
|
|
31
|
+
// Lifecycle writes follow declaration order, including overlapping descriptors.
|
|
32
|
+
all: FragmentFocusStyleTrack[];
|
|
33
|
+
focusPercent: FragmentFocusStyleTrack[];
|
|
34
|
+
rowFocusPercent: FragmentFocusStyleTrack[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function compilePair(start: Endpoint, target: Endpoint): EndpointPair {
|
|
38
|
+
if (typeof start === 'string') {
|
|
39
|
+
return { start, target, startColor: colorToRgba(start), targetColor: colorToRgba(target as string) };
|
|
40
|
+
}
|
|
41
|
+
return { start, target };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function isEndpoint(field: string, value: unknown): value is Endpoint {
|
|
45
|
+
if (field === 'opacity' || field === 'width') return typeof value === 'number' && Number.isFinite(value);
|
|
46
|
+
if (field === 'scale' || field === 'translation') {
|
|
47
|
+
return Array.isArray(value) && value.length === 2
|
|
48
|
+
&& typeof value[0] === 'number' && Number.isFinite(value[0])
|
|
49
|
+
&& typeof value[1] === 'number' && Number.isFinite(value[1]);
|
|
50
|
+
}
|
|
51
|
+
if (field === 'color' || field === 'blendColor') {
|
|
52
|
+
return isHexColor(value) && value.startsWith('#');
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Resolve static endpoints and nodes once per fragment, outside the focus tick. */
|
|
58
|
+
export function compileFragmentFocusStyle(style: IFragmentStyle, nodes: Record<string, ISGNNode>): FragmentFocusStyleTracks {
|
|
59
|
+
const tracks: FragmentFocusStyleTracks = { all: [], focusPercent: [], rowFocusPercent: [] };
|
|
60
|
+
const descriptors = Array.isArray(style.animated) ? style.animated : [style.animated];
|
|
61
|
+
for (const descriptor of descriptors) {
|
|
62
|
+
if (!descriptor || (descriptor.progress !== 'focusPercent' && descriptor.progress !== 'rowFocusPercent')) continue;
|
|
63
|
+
for (const id in descriptor.properties) {
|
|
64
|
+
const node = nodes[id];
|
|
65
|
+
const fields = descriptor.properties[id];
|
|
66
|
+
if (!node || !Array.isArray(fields)) continue;
|
|
67
|
+
const normal = style.views.normal?.[id] as JsonData | undefined;
|
|
68
|
+
const focused = style.views.focused?.[id] as JsonData | undefined;
|
|
69
|
+
const footprint = style.views.focusFootprint?.[id] as JsonData | undefined;
|
|
70
|
+
const selected = style.views.selected?.[id] as JsonData | undefined;
|
|
71
|
+
const focusSelected = style.views.focusSelected?.[id] as JsonData | undefined;
|
|
72
|
+
for (const field of fields) {
|
|
73
|
+
if (__ROKU__) {
|
|
74
|
+
// The shape status resolver owns Poster offsets and the matching load dimensions.
|
|
75
|
+
if ((field === 'width' || field === 'translation') && (style as unknown as JsonData).hsShapeGeometryById?.[id]) continue;
|
|
76
|
+
}
|
|
77
|
+
const from = normal?.[field];
|
|
78
|
+
const target = focused?.[field];
|
|
79
|
+
if (!isEndpoint(field, from) || !isEndpoint(field, target)) continue;
|
|
80
|
+
const selectedFrom = selected?.[field];
|
|
81
|
+
const selectedTo = focusSelected?.[field];
|
|
82
|
+
const normalPair = compilePair(from, target);
|
|
83
|
+
const hasSelectedFrom = isEndpoint(field, selectedFrom);
|
|
84
|
+
const hasSelectedTo = isEndpoint(field, selectedTo);
|
|
85
|
+
let selectedPair = normalPair;
|
|
86
|
+
if (hasSelectedFrom || hasSelectedTo) {
|
|
87
|
+
selectedPair = compilePair(hasSelectedFrom ? selectedFrom : from, hasSelectedTo ? selectedTo : target);
|
|
88
|
+
}
|
|
89
|
+
let kind = FieldKind.Scalar;
|
|
90
|
+
if (typeof from === 'string') kind = FieldKind.Color;
|
|
91
|
+
else if (Array.isArray(from)) kind = FieldKind.Vector;
|
|
92
|
+
const footprintFrom = footprint?.[field];
|
|
93
|
+
let footprintPair: EndpointPair | undefined = normalPair;
|
|
94
|
+
if (footprintFrom !== undefined) {
|
|
95
|
+
// Leave a computed footprint override to the status resolver.
|
|
96
|
+
footprintPair = isEndpoint(field, footprintFrom) ? compilePair(footprintFrom, target) : undefined;
|
|
97
|
+
}
|
|
98
|
+
// A nonliteral value belongs to the status resolver while that status is active.
|
|
99
|
+
const track = {
|
|
100
|
+
progress: descriptor.progress, node, field, kind, normal: normalPair,
|
|
101
|
+
selected: selectedFrom === undefined || hasSelectedFrom ? selectedPair : undefined,
|
|
102
|
+
focusSelected: selectedTo === undefined || hasSelectedTo ? selectedPair : undefined,
|
|
103
|
+
focusFootprint: footprintPair,
|
|
104
|
+
};
|
|
105
|
+
tracks.all.push(track);
|
|
106
|
+
tracks[descriptor.progress].push(track);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return tracks;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function statusOverridesFragmentFocusStyle(status: ViewStatus): boolean {
|
|
114
|
+
return status === ViewStatus.Disabled || status === ViewStatus.Error || status === ViewStatus.Interacted;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function applyTracks(tracks: FragmentFocusStyleTrack[], fragment: IViewFragment, status: ViewStatus, percent?: number): void {
|
|
118
|
+
if (statusOverridesFragmentFocusStyle(status)) return;
|
|
119
|
+
let pairKey: 'normal' | 'selected' | 'focusSelected' | 'focusFootprint' = 'normal';
|
|
120
|
+
if (status === ViewStatus.Selected) pairKey = 'selected';
|
|
121
|
+
else if (status === ViewStatus.FocusSelected) pairKey = 'focusSelected';
|
|
122
|
+
else if (status === ViewStatus.FocusFootprint) pairKey = 'focusFootprint';
|
|
123
|
+
for (const track of tracks) {
|
|
124
|
+
const pair = track[pairKey];
|
|
125
|
+
if (pair === undefined) continue;
|
|
126
|
+
let fraction = percent;
|
|
127
|
+
if (fraction === undefined) {
|
|
128
|
+
fraction = fragment[track.progress] ?? (status === ViewStatus.Focused || status === ViewStatus.FocusSelected ? 1 : 0);
|
|
129
|
+
}
|
|
130
|
+
const start = pair.start;
|
|
131
|
+
let value: Endpoint;
|
|
132
|
+
if (fraction <= 0) value = start;
|
|
133
|
+
else if (fraction >= 1) value = pair.target;
|
|
134
|
+
else if (track.kind === FieldKind.Scalar) value = (start as number) + ((pair.target as number) - (start as number)) * fraction;
|
|
135
|
+
else if (track.kind === FieldKind.Color) value = colorToHex(blendColors(pair.startColor!, pair.targetColor!, fraction));
|
|
136
|
+
else value = interpolatePoint(start as number[], pair.target as number[], fraction);
|
|
137
|
+
(track.node as JsonData)[track.field] = value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function applyFragmentFocusStyle(fragment: IViewFragment, percent?: number, status = fragment.viewStatus): void {
|
|
142
|
+
if (fragment.focusStyleTracks) applyTracks(fragment.focusStyleTracks.all, fragment, status, percent);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function applyFragmentItemFocusStyle(fragment: IViewFragment, percent: number): void {
|
|
146
|
+
applyTracks(fragment.focusStyleTracks!.focusPercent, fragment, fragment.viewStatus, percent);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function applyFragmentRowFocusStyle(fragment: IViewFragment, percent: number): void {
|
|
150
|
+
applyTracks(fragment.focusStyleTracks!.rowFocusPercent, fragment, fragment.viewStatus, percent);
|
|
151
|
+
}
|