@tantawowa/hosanna-ui 2.0.4 → 2.2.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.
Files changed (30) hide show
  1. package/dist-manifest.json +33 -29
  2. package/package.json +1 -1
  3. package/src/hosanna-bridge-core/color.ts +140 -0
  4. package/src/hosanna-bridge-targets/web/brs/WebRoBitmap.ts +14 -0
  5. package/src/hosanna-bridge-targets/web/sg/WebSGPoster.ts +1 -1
  6. package/src/hosanna-game/color.ts +3 -115
  7. package/src/hosanna-list/BaseCell.ts +4 -0
  8. package/src/hosanna-list/BaseCollectionViewLayout.ts +59 -6
  9. package/src/hosanna-list/CollectionView.ts +14 -5
  10. package/src/hosanna-list/CollectionViewAPI.ts +41 -5
  11. package/src/hosanna-list/CollectionViewFocusManager.ts +415 -6
  12. package/src/hosanna-list/CollectionViewSupplementaryView.ts +49 -1
  13. package/src/hosanna-list/DynamicCell.ts +132 -2
  14. package/src/hosanna-list/EPGProgramLayout.ts +1 -0
  15. package/src/hosanna-list/GridRowLayout.ts +1 -0
  16. package/src/hosanna-list/HorizontalRowLayout.ts +1 -0
  17. package/src/hosanna-list/ListRowLayout.ts +1 -0
  18. package/src/hosanna-ui/app-roku/HosannaApp.xml +2 -1
  19. package/src/hosanna-ui/async/ImageGeneratorCommands.ts +0 -20
  20. package/src/hosanna-ui/lib/BaseApp.ts +11 -6
  21. package/src/hosanna-ui/lib/ConfigurationLoader.ts +11 -3
  22. package/src/hosanna-ui/lib/FragmentUtils.ts +26 -10
  23. package/src/hosanna-ui/lib/animation.ts +358 -235
  24. package/src/hosanna-ui/lib/shapes/ShapeLoader.ts +22 -27
  25. package/src/hosanna-ui/views/controls/Button.ts +16 -1
  26. package/src/hosanna-ui/views/lib/AppConfig.ts +26 -0
  27. package/src/hosanna-ui/views/lib/BaseView.ts +98 -21
  28. package/src/hosanna-ui/views/lib/ViewFragmentProvider.ts +39 -5
  29. package/src/hosanna-ui/views/primitives/Image.ts +1 -1
  30. package/src/hosanna-ui/views/primitives/Label.ts +3 -3
@@ -290,6 +290,9 @@ export class BaseCollectionViewLayout {
290
290
  this.lastHeaderVisibility = undefined;
291
291
  this.applyMeasuredSupplementaryHeight('header', this.headerSupplementaryView.getMeasuredHeight());
292
292
  this.hasHeader = this.headerSupplementaryView.getShouldDisplay();
293
+ if (this.row.isOnScreen && this.hasHeader && this.headerSupplementaryView.supportsRowFocusPercent) {
294
+ this.row.parent?.getFocusManager?.().registerRowFocusPercentHeader?.(this.row.index, this.headerSupplementaryView, true);
295
+ }
293
296
 
294
297
  if (this.headerLabel) {
295
298
  this.headerLabel.visible = false;
@@ -544,6 +547,7 @@ export class BaseCollectionViewLayout {
544
547
  // cell (~40ms/row of applyDataMap + computed + constraints). Cells are only truly
545
548
  // released on reset / hidden-row / pool-release (see releaseAllCells / onWillRelease).
546
549
  for (const cell of this.renderedCells) {
550
+ cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
547
551
  cell.setVisible(false);
548
552
  }
549
553
  // Cells are hidden above; clear the scroll throttle key so the next calculateVisibleCells
@@ -618,14 +622,19 @@ export class BaseCollectionViewLayout {
618
622
  * can use different styles.
619
623
  *
620
624
  * @param index - The index of the cell to retrieve.
625
+ * @param deferVisibility - Let configureCell finish binding before showing the cell.
621
626
  * @returns The cell at the specified index, or a newly reserved cell if it did not exist.
622
627
  * @throws A warning if no cells are available in the instancePool.
623
628
  */
624
- getCell(index: number): ICollectionViewCell {
629
+ getCell(index: number, deferVisibility = false): ICollectionViewCell {
625
630
  let cell: BaseCell | undefined = this.cellsByIndex[index.toString()];
626
631
  if (cell !== undefined) {
627
632
  // Retained cells are hidden on exit (see onExitScreen); ensure they are shown again on reuse.
628
- cell.setVisible(true);
633
+ if (deferVisibility === false) {
634
+ if ((cell as ICollectionViewCell).supportsFocusPercent !== true) {
635
+ if ((cell as ICollectionViewCell).supportsRowFocusPercent !== true) cell.setVisible(true);
636
+ }
637
+ }
629
638
  // Retained cells keep the viewStatus they had when the row scrolled away, which can be a
630
639
  // stale Focused (focus left the CV while this cell was off-screen). Re-derive the correct
631
640
  // status on every materialization; applyViewStatus no-ops when unchanged, so this costs a
@@ -649,8 +658,12 @@ export class BaseCollectionViewLayout {
649
658
  key = cellSettingsKey;
650
659
  }
651
660
  cell = this.instancePool.get<DynamicCell>(key, DynamicCell);
652
- if (cell) {
653
- cell.setVisible(true);
661
+ if (cell !== undefined) {
662
+ if (deferVisibility === false) {
663
+ if ((cell as ICollectionViewCell).supportsFocusPercent !== true) {
664
+ if ((cell as ICollectionViewCell).supportsRowFocusPercent !== true) cell.setVisible(true);
665
+ }
666
+ }
654
667
  cell.index = index;
655
668
  cell.applyViewStatus(this.getExpectedCellViewStatus(index, cell.viewStatus));
656
669
  this.cellsByIndex[index.toString()] = cell;
@@ -902,6 +915,14 @@ export class BaseCollectionViewLayout {
902
915
  )
903
916
  ) {
904
917
  if (this.headerSupplementaryView) {
918
+ if (this.headerSupplementaryView.supportsRowFocusPercent) {
919
+ const focusManager = this.row.parent?.getFocusManager?.();
920
+ if (headerVisibility) {
921
+ focusManager?.registerRowFocusPercentHeader?.(this.row.index, this.headerSupplementaryView);
922
+ } else {
923
+ focusManager?.unregisterRowFocusPercentHeader?.(this.headerSupplementaryView);
924
+ }
925
+ }
905
926
  this.headerSupplementaryView.setVisible(headerVisibility);
906
927
  } else if (this.headerFragment) {
907
928
  this.headerFragment.view.visible = headerVisibility;
@@ -1076,6 +1097,7 @@ export class BaseCollectionViewLayout {
1076
1097
  if (__SCROLL_JANK_TELEMETRY__) {
1077
1098
  scrollJankLog('cell-flag-remove', `layout=base rowIndex=${row.index} rowId=${row.id} cellIndex=${cell.index} itemId=${cell.item?.id ?? ''} reason=not-visible`);
1078
1099
  }
1100
+ cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
1079
1101
  cell.setVisible(false);
1080
1102
  this.instancePool.release(cell);
1081
1103
  if (__SCROLL_JANK_TELEMETRY__) {
@@ -1100,6 +1122,7 @@ export class BaseCollectionViewLayout {
1100
1122
  if (__SCROLL_JANK_TELEMETRY__) {
1101
1123
  scrollJankLog('cell-flag-remove', `layout=base rowIndex=${row.index} rowId=${row.id} cellIndex=${cell.index} itemId=${cell.item?.id ?? ''} reason=release-all`);
1102
1124
  }
1125
+ cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
1103
1126
  cell.reset();
1104
1127
  cell.setVisible(false);
1105
1128
  this.instancePool.release(cell);
@@ -1172,13 +1195,23 @@ export class BaseCollectionViewLayout {
1172
1195
  if (__SCROLL_JANK_TELEMETRY__) {
1173
1196
  scrollJankStartMs = scrollJankNow();
1174
1197
  }
1175
- const cell = this.getCell(index);
1198
+ const cell = this.getCell(index, true);
1176
1199
  if (cell) {
1177
1200
  if (__SCROLL_JANK_TELEMETRY__) {
1178
1201
  scrollJankLog('configure-cell-start', `layout=base rowIndex=${this.row.index} rowId=${this.row.id} cellIndex=${index} itemId=${content?.id ?? ''} hasExistingItem=${cell.item !== undefined}`);
1179
1202
  }
1180
- //Possibly want to imrpove how we set content
1203
+ // Bind before showing a newly acquired or retained hidden presentation.
1204
+ // Read capabilities afterwards: content/status callbacks may change them.
1181
1205
  cell.setContent(this.row, content);
1206
+ if (cell.supportsFocusPercent === true) {
1207
+ this.syncCellFocusPercent(cell);
1208
+ } else if (cell.supportsRowFocusPercent === true) {
1209
+ this.syncCellFocusPercent(cell);
1210
+ } else if (cell._focusPercentRegistration !== undefined) {
1211
+ const owner = cell._focusPercentRegistration.owner;
1212
+ if (owner !== undefined) owner.unregisterFocusPercentCell?.(cell);
1213
+ }
1214
+ (cell as BaseCell).setVisible(true);
1182
1215
  if (__SCROLL_JANK_TELEMETRY__) {
1183
1216
  scrollJankLog('configure-cell-end', `layout=base rowIndex=${this.row.index} rowId=${this.row.id} cellIndex=${index} itemId=${content?.id ?? ''} durationMs=${scrollJankDuration(scrollJankStartMs)}`);
1184
1217
  }
@@ -1188,6 +1221,23 @@ export class BaseCollectionViewLayout {
1188
1221
  return cell! as BaseCell;
1189
1222
  }
1190
1223
 
1224
+ /** Completes opt-in binding before a deferred cell becomes visible. */
1225
+ private syncCellFocusPercent(cell: ICollectionViewCell): void {
1226
+ if (cell.supportsFocusPercent || cell.supportsRowFocusPercent) {
1227
+ const registration = cell._focusPercentRegistration;
1228
+ if (registration?.owner === undefined || registration.needsInitialization
1229
+ || registration.itemIndex !== cell.index
1230
+ || registration.supportsFocusPercent !== (cell.supportsFocusPercent === true)
1231
+ || registration.supportsRowFocusPercent !== (cell.supportsRowFocusPercent === true)
1232
+ || (cell.supportsFocusPercent && cell.focusPercent === undefined)
1233
+ || (cell.supportsRowFocusPercent && cell.rowFocusPercent === undefined)) {
1234
+ this.row.parent?.getFocusManager?.().registerFocusPercentCell?.(cell);
1235
+ }
1236
+ } else if (cell._focusPercentRegistration?.owner !== undefined) {
1237
+ cell._focusPercentRegistration.owner.unregisterFocusPercentCell?.(cell);
1238
+ }
1239
+ }
1240
+
1191
1241
  // IReusable implementation
1192
1242
 
1193
1243
  /**
@@ -1407,6 +1457,9 @@ export class BaseCollectionViewLayout {
1407
1457
 
1408
1458
  protected releaseHeaderSupplementaryView(): void {
1409
1459
  if (this.headerSupplementaryView) {
1460
+ if (this.headerSupplementaryView.supportsRowFocusPercent) {
1461
+ this.row.parent?.getFocusManager?.().unregisterRowFocusPercentHeader?.(this.headerSupplementaryView);
1462
+ }
1410
1463
  if (this.headerSupplementaryViewIsPooled) {
1411
1464
  this.instancePool.release(this.headerSupplementaryView);
1412
1465
  } else {
@@ -22,7 +22,7 @@ import { InstancePool } from '@hs-src/hosanna-ui/lib/InstancePool';
22
22
  import { scrollJankDuration, scrollJankLog, scrollJankNow } from '@hs-src/hosanna-ui/lib/ScrollJankLogger';
23
23
  import { BaseApp } from '@hs-src/hosanna-ui/lib/BaseApp';
24
24
  import { state, view } from '@hs-src/hosanna-ui/lib/decorators';
25
- import { getUniqueViewId, IHosannaView, NextViewFocus, ViewEvent, ViewEventHandler, ViewState } from '@hs-src/hosanna-ui/views/lib/view-api';
25
+ import { getUniqueViewId, IHosannaView, NextViewFocus, ViewEvent, ViewEventHandler, ViewState, FocusChildChangeEvent } from '@hs-src/hosanna-ui/views/lib/view-api';
26
26
  import { BaseView } from '@hs-src/hosanna-ui/views/lib/BaseView';
27
27
  import { ViewPhase } from '@hs-src/hosanna-ui/lib/renderer-api';
28
28
  import { Direction, ViewStatus } from '@hs-src/hosanna-ui/hosanna-api';
@@ -4692,6 +4692,7 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
4692
4692
  this.clearSupplementaryFocus(false);
4693
4693
  }
4694
4694
  this.focusedSupplementary = { kind, rowIndex };
4695
+ this.collectionViewFocusManager.setFocusPercentSupplementary?.(rowIndex);
4695
4696
  supplementary.setFocused(true);
4696
4697
  this.collectionViewFocusManager.applyCellViewStatus(
4697
4698
  this.focusedIndices[0],
@@ -4707,6 +4708,7 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
4707
4708
  private clearSupplementaryFocus(restoreCellGraphics: boolean): void {
4708
4709
  const focused = this.focusedSupplementary;
4709
4710
  this.focusedSupplementary = undefined;
4711
+ this.collectionViewFocusManager.setFocusPercentSupplementary?.();
4710
4712
  if (focused) {
4711
4713
  this.getSupplementaryView(focused.rowIndex, focused.kind)?.setFocused(false);
4712
4714
  }
@@ -5035,20 +5037,26 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
5035
5037
  * Uses the same vertical math as {@link jumpToRow} so grid rows scrolled within
5036
5038
  * the collection stay aligned after blur/focus or aggregate reappear.
5037
5039
  */
5038
- private syncFocusIndicatorToFocusedItem(): void {
5040
+ private syncFocusIndicatorToFocusedItem(preserveFocusPercentTransition = false): void {
5039
5041
  const rowIndex = clamp(this.focusedIndices[0], 0, this.rows.length - 1);
5040
5042
  const focusedRow = this.rows[rowIndex];
5041
5043
  if (!focusedRow) {
5042
5044
  return;
5043
5045
  }
5044
5046
  const itemIndex = clamp(this.focusedIndices[1], 0, focusedRow.layout.numberOfItems - 1);
5045
- this.collectionViewFocusManager.setAndRenderFocusInfo(this.getFocusInfo(rowIndex, itemIndex));
5047
+ this.collectionViewFocusManager.setAndRenderFocusInfo(this.getFocusInfo(rowIndex, itemIndex), preserveFocusPercentTransition);
5048
+ }
5049
+
5050
+ override notifyOnFocusedChildChange(event: FocusChildChangeEvent): void {
5051
+ this.collectionViewFocusManager.syncFocusPercentFocusChain?.();
5052
+ super.notifyOnFocusedChildChange(event);
5046
5053
  }
5047
5054
 
5048
5055
  /**
5049
5056
  * Called when the collection view receives focus.
5050
5057
  */
5051
5058
  override onFocus(): void {
5059
+ this.collectionViewFocusManager.syncFocusPercentFocusChain?.();
5052
5060
  if (this.isInternalRefocusing) {
5053
5061
  console.debug('CollectionView is internal refocusing, skipping focus');
5054
5062
  return;
@@ -5069,7 +5077,7 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
5069
5077
  const focusedRow = this.rows[this.focusedIndices[0]];
5070
5078
  if (focusedRow) {
5071
5079
  console.debug('Setting focus info for focused row', this.focusedIndices[0]);
5072
- this.syncFocusIndicatorToFocusedItem();
5080
+ this.syncFocusIndicatorToFocusedItem(true);
5073
5081
  } else {
5074
5082
  console.debug('No focused row found, setting focus info for first row');
5075
5083
  };
@@ -5082,6 +5090,7 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
5082
5090
  * Called when the collection view loses focus.
5083
5091
  */
5084
5092
  override onBlur(): void {
5093
+ this.collectionViewFocusManager.syncFocusPercentFocusChain?.();
5085
5094
  if (this.isInternalRefocusing) {
5086
5095
  // Clear so that when we leave the screen (e.g. press OK to navigate), the next onFocus runs. Key release
5087
5096
  // may be handled by the new screen, so we might never get a chance to set this to false.
@@ -5098,7 +5107,7 @@ export class CollectionViewView extends BaseView<CollectionViewState, ISGNGroup>
5098
5107
  )?.setFocused(false);
5099
5108
  return;
5100
5109
  }
5101
- this.syncFocusIndicatorToFocusedItem();
5110
+ this.syncFocusIndicatorToFocusedItem(true);
5102
5111
  this.collectionViewFocusManager.applyFocusToRow(false);
5103
5112
  this.dispatchRowItemFocusEventForFocus(false);
5104
5113
  this.focusEventStateManager.resetDirectChangeFlags();
@@ -250,6 +250,17 @@ export interface ICollectionView extends IHosannaView<ViewState> {
250
250
  * Handles rendering and updating focus info and animations.
251
251
  */
252
252
  export interface ICollectionViewFocusManager {
253
+ /** Registers a realized cell after its content and optional progress callbacks are bound. */
254
+ registerFocusPercentCell?(cell: ICollectionViewCell, force?: boolean): void;
255
+ /** Detaches a cell before hiding, rebinding or releasing it. */
256
+ unregisterFocusPercentCell?(cell: ICollectionViewCell): void;
257
+ /** Registers a visible complex header; legacy label headers never participate. */
258
+ registerRowFocusPercentHeader?(rowIndex: number, header: ICollectionViewRowFocusPercentHeader, force?: boolean): void;
259
+ unregisterRowFocusPercentHeader?(header: ICollectionViewRowFocusPercentHeader): void;
260
+ /** Reconciles effective focus without changing navigation or the active progress pair. */
261
+ syncFocusPercentFocusChain?(): void;
262
+ /** Uses -1 when ordinary item focus replaces supplementary focus. */
263
+ setFocusPercentSupplementary?(rowIndex?: number): void;
253
264
  /** Applies the cell view status. */
254
265
  applyCellViewStatus(rowIndex: number, itemIndex: number, focused: boolean, isFootprint?: boolean): void;
255
266
  /** Starts the active strategy's gesture-level long-press lifecycle. */
@@ -267,7 +278,7 @@ export interface ICollectionViewFocusManager {
267
278
  /** Suppresses or restores focus indicator visibility without changing committed focus. */
268
279
  setFocusIndicatorSuppressed?(suppressed: boolean): void;
269
280
  /** Sets and renders the focus info. */
270
- setAndRenderFocusInfo(info: IFocusInfo | undefined): void;
281
+ setAndRenderFocusInfo(info: IFocusInfo | undefined, preserveFocusPercentTransition?: boolean): void;
271
282
  /** Renders the next focus info. */
272
283
  renderNextFocusInfo(): void;
273
284
  /** Sets the next focus info for animation or transition. */
@@ -697,11 +708,30 @@ export function createFocusInfoForRowItem(
697
708
  return info;
698
709
  }
699
710
 
700
- /**
701
- * Interface for a collection view cell.
702
- * Extends IReusable.
703
- */
711
+ /** @internal Reusable cell-owned storage; only active bindings have an owner. */
712
+ export interface ICollectionViewFocusPercentRegistration {
713
+ owner?: ICollectionViewFocusManager;
714
+ ownerId: string;
715
+ cell?: ICollectionViewCell;
716
+ rowKey: string;
717
+ itemIndex: number;
718
+ rowCellIndex: number;
719
+ supportsFocusPercent: boolean;
720
+ supportsRowFocusPercent: boolean;
721
+ needsInitialization: boolean;
722
+ }
723
+
724
+ /** Interface for a collection view cell. Extends IReusable. */
704
725
  export interface ICollectionViewCell extends IReusable {
726
+ /** @internal Retained through pooling, detached from the manager when hidden. */
727
+ _focusPercentRegistration?: ICollectionViewFocusPercentRegistration;
728
+ /** Optional presentation capabilities, resolved when the cell's fragment is acquired. */
729
+ supportsFocusPercent?: boolean;
730
+ supportsRowFocusPercent?: boolean;
731
+ focusPercent?: number;
732
+ rowFocusPercent?: number;
733
+ /** Stores both supported values before notifying either callback. */
734
+ setFocusPercents?(focusPercent: number, rowFocusPercent: number, force?: boolean): void;
705
735
  /** The item associated with the cell. */
706
736
  item?: IIdentifiable;
707
737
  /** The row this cell belongs to. */
@@ -722,6 +752,12 @@ export interface ICollectionViewCell extends IReusable {
722
752
  getFocusHolder(): ISGNGroup | undefined;
723
753
  }
724
754
 
755
+ /** Narrow reusable-header contract for CollectionView-owned row focus presentation. */
756
+ export interface ICollectionViewRowFocusPercentHeader extends IReusable {
757
+ supportsRowFocusPercent: boolean;
758
+ setRowFocusPercent(percent: number, force?: boolean): void;
759
+ }
760
+
725
761
  /*******************************************************************
726
762
  * Data Source
727
763
  *******************************************************************/