@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.
- package/dist-manifest.json +33 -29
- package/package.json +1 -1
- package/src/hosanna-bridge-core/color.ts +140 -0
- package/src/hosanna-bridge-targets/web/brs/WebRoBitmap.ts +14 -0
- package/src/hosanna-bridge-targets/web/sg/WebSGPoster.ts +1 -1
- package/src/hosanna-game/color.ts +3 -115
- package/src/hosanna-list/BaseCell.ts +4 -0
- package/src/hosanna-list/BaseCollectionViewLayout.ts +59 -6
- package/src/hosanna-list/CollectionView.ts +14 -5
- package/src/hosanna-list/CollectionViewAPI.ts +41 -5
- package/src/hosanna-list/CollectionViewFocusManager.ts +415 -6
- package/src/hosanna-list/CollectionViewSupplementaryView.ts +49 -1
- package/src/hosanna-list/DynamicCell.ts +132 -2
- package/src/hosanna-list/EPGProgramLayout.ts +1 -0
- package/src/hosanna-list/GridRowLayout.ts +1 -0
- package/src/hosanna-list/HorizontalRowLayout.ts +1 -0
- package/src/hosanna-list/ListRowLayout.ts +1 -0
- package/src/hosanna-ui/app-roku/HosannaApp.xml +2 -1
- package/src/hosanna-ui/async/ImageGeneratorCommands.ts +0 -20
- package/src/hosanna-ui/lib/BaseApp.ts +11 -6
- package/src/hosanna-ui/lib/ConfigurationLoader.ts +11 -3
- package/src/hosanna-ui/lib/FragmentUtils.ts +26 -10
- package/src/hosanna-ui/lib/animation.ts +358 -235
- package/src/hosanna-ui/lib/shapes/ShapeLoader.ts +22 -27
- package/src/hosanna-ui/views/controls/Button.ts +16 -1
- package/src/hosanna-ui/views/lib/AppConfig.ts +26 -0
- package/src/hosanna-ui/views/lib/BaseView.ts +98 -21
- package/src/hosanna-ui/views/lib/ViewFragmentProvider.ts +39 -5
- package/src/hosanna-ui/views/primitives/Image.ts +1 -1
- package/src/hosanna-ui/views/primitives/Label.ts +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { inject } from '@hs-src/hosanna-bridge-core/decorators';
|
|
2
2
|
import { BaseCell } from './BaseCell';
|
|
3
3
|
import { IViewFragmentProvider } from '@hs-src/hosanna-ui/views/lib/ViewFragmentProvider';
|
|
4
|
-
import { IAppConfig, IViewFragment, IViewFragmentStyle, ViewFragmentCallbackHandler, ViewFragmentCallbackType } from '@hs-src/hosanna-ui/views/lib/AppConfig';
|
|
4
|
+
import { IAppConfig, IViewFragment, IViewFragmentStyle, ViewFragmentCallbackHandler, ViewFragmentCallbackType, ViewFragmentFocusPercentCallbackHandler } from '@hs-src/hosanna-ui/views/lib/AppConfig';
|
|
5
5
|
import { applyDataMap } from '@hs-src/hosanna-ui/lib/FragmentUtils';
|
|
6
6
|
import { scrollJankChildCount, scrollJankDuration, scrollJankLog, scrollJankNodeId, scrollJankNow } from '@hs-src/hosanna-ui/lib/ScrollJankLogger';
|
|
7
7
|
import {
|
|
@@ -22,7 +22,7 @@ import { ViewStatus } from '@hs-src/hosanna-ui/hosanna-api';
|
|
|
22
22
|
import { IIdentifiable } from '@hs-src/hosanna-bridge-core/brs-api';
|
|
23
23
|
import { ISGNGroup } from '@hs-src/hosanna-bridge-targets/common/sg-api';
|
|
24
24
|
import { JsonData } from '@hs-src/hosanna-ui/async/AsyncApi';
|
|
25
|
-
import { IBaseCollectionViewRow, ILoadingItem } from './CollectionViewAPI';
|
|
25
|
+
import { IBaseCollectionViewRow, ICollectionViewFocusManager, ILoadingItem } from './CollectionViewAPI';
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* `DynamicCell` is an extension of `BaseCell` that dynamically manages its view fragment.
|
|
@@ -48,11 +48,31 @@ export class DynamicCell extends BaseCell {
|
|
|
48
48
|
|
|
49
49
|
private constraintSession: FragmentConstraintSession | undefined;
|
|
50
50
|
|
|
51
|
+
/** Cached fragment capabilities; unsupported cells never receive progress work. */
|
|
52
|
+
supportsFocusPercent = false;
|
|
53
|
+
supportsRowFocusPercent = false;
|
|
54
|
+
focusPercent: number | undefined;
|
|
55
|
+
rowFocusPercent: number | undefined;
|
|
56
|
+
private focusPercentCallbacks: ViewFragmentFocusPercentCallbackHandler[] | undefined;
|
|
57
|
+
private rowFocusPercentCallbacks: ViewFragmentFocusPercentCallbackHandler[] | undefined;
|
|
58
|
+
private focusPercentManager: ICollectionViewFocusManager | undefined;
|
|
59
|
+
|
|
51
60
|
/**
|
|
52
61
|
* Handles content changes for the cell.
|
|
53
62
|
* Updates the view fragment and applies the current view status.
|
|
54
63
|
*/
|
|
55
64
|
protected changeRowHidden(item: IIdentifiable | undefined) {
|
|
65
|
+
// BaseCell has assigned the new row already; detach through the previous binding's owner.
|
|
66
|
+
if (this.focusPercentManager !== undefined) {
|
|
67
|
+
this.detachFocusPercent();
|
|
68
|
+
} else if (this._focusPercentRegistration?.owner !== undefined) {
|
|
69
|
+
this.detachFocusPercent();
|
|
70
|
+
}
|
|
71
|
+
if (this.supportsFocusPercent) {
|
|
72
|
+
this.clearFocusPercentValues();
|
|
73
|
+
} else if (this.supportsRowFocusPercent) {
|
|
74
|
+
this.clearFocusPercentValues();
|
|
75
|
+
}
|
|
56
76
|
let scrollJankStartMs = 0;
|
|
57
77
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
58
78
|
scrollJankStartMs = scrollJankNow();
|
|
@@ -89,6 +109,7 @@ export class DynamicCell extends BaseCell {
|
|
|
89
109
|
}
|
|
90
110
|
|
|
91
111
|
this.viewFragment = this.viewFragmentProvider.getViewFragmentByStyleKey(styleKey);
|
|
112
|
+
this.cacheFocusPercentCallbacks();
|
|
92
113
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
93
114
|
scrollJankLog('fragment-acquire-for-cell', `rowIndex=${row.index} rowId=${row.id} cellIndex=${this.index} itemId=${item?.id ?? ''} styleKey=${styleKey} fragmentId=${this.viewFragment?.id ?? ''} viewId=${scrollJankNodeId(this.viewFragment?.view)} parentId=${scrollJankNodeId(this.viewFragment?.view?.getParent?.())}`);
|
|
94
115
|
}
|
|
@@ -352,6 +373,13 @@ export class DynamicCell extends BaseCell {
|
|
|
352
373
|
* @param visible - Whether the cell should be visible.
|
|
353
374
|
*/
|
|
354
375
|
override setVisible(visible: boolean) {
|
|
376
|
+
if (!visible) {
|
|
377
|
+
if (this.focusPercentManager !== undefined) {
|
|
378
|
+
this.detachFocusPercent();
|
|
379
|
+
} else if (this._focusPercentRegistration?.owner !== undefined) {
|
|
380
|
+
this.detachFocusPercent();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
355
383
|
if (this.viewFragment) {
|
|
356
384
|
this.viewFragment.view.visible = visible;
|
|
357
385
|
}
|
|
@@ -364,6 +392,97 @@ export class DynamicCell extends BaseCell {
|
|
|
364
392
|
}
|
|
365
393
|
}
|
|
366
394
|
|
|
395
|
+
/** Applies only requested progress fields, without replaying content, status, or layout. */
|
|
396
|
+
setFocusPercents(focusPercent: number, rowFocusPercent: number, force = false): void {
|
|
397
|
+
const fragment = this.viewFragment;
|
|
398
|
+
if (fragment === undefined) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const focusChanged = this.supportsFocusPercent && (force || this.focusPercent !== focusPercent);
|
|
402
|
+
const rowFocusChanged = this.supportsRowFocusPercent && (force || this.rowFocusPercent !== rowFocusPercent);
|
|
403
|
+
if (!focusChanged && !rowFocusChanged) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
if (this.focusPercentManager === undefined) {
|
|
407
|
+
this.focusPercentManager = this.row?.parent?.getFocusManager?.();
|
|
408
|
+
}
|
|
409
|
+
// Publish both values before either callback so combined effects see one sample.
|
|
410
|
+
if (focusChanged) {
|
|
411
|
+
this.focusPercent = focusPercent;
|
|
412
|
+
fragment.focusPercent = focusPercent;
|
|
413
|
+
}
|
|
414
|
+
if (rowFocusChanged) {
|
|
415
|
+
this.rowFocusPercent = rowFocusPercent;
|
|
416
|
+
fragment.rowFocusPercent = rowFocusPercent;
|
|
417
|
+
}
|
|
418
|
+
if (focusChanged && this.focusPercentCallbacks) {
|
|
419
|
+
for (const callback of this.focusPercentCallbacks) {
|
|
420
|
+
callback(fragment, focusPercent);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
if (rowFocusChanged && this.rowFocusPercentCallbacks) {
|
|
424
|
+
for (const callback of this.rowFocusPercentCallbacks) {
|
|
425
|
+
callback(fragment, rowFocusPercent);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
private cacheFocusPercentCallbacks(): void {
|
|
431
|
+
this.focusPercentCallbacks = this.viewFragment?.callbacks?.onFocusPercentChanged;
|
|
432
|
+
this.rowFocusPercentCallbacks = this.viewFragment?.callbacks?.onRowFocusPercentChanged;
|
|
433
|
+
this.supportsFocusPercent = false;
|
|
434
|
+
if (this.focusPercentCallbacks !== undefined) {
|
|
435
|
+
this.supportsFocusPercent = this.focusPercentCallbacks.length > 0;
|
|
436
|
+
}
|
|
437
|
+
this.supportsRowFocusPercent = false;
|
|
438
|
+
if (this.rowFocusPercentCallbacks !== undefined) {
|
|
439
|
+
this.supportsRowFocusPercent = this.rowFocusPercentCallbacks.length > 0;
|
|
440
|
+
}
|
|
441
|
+
if (this.supportsFocusPercent) {
|
|
442
|
+
this.clearFocusPercentValues();
|
|
443
|
+
} else if (this.supportsRowFocusPercent) {
|
|
444
|
+
this.clearFocusPercentValues();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
private detachFocusPercent(): void {
|
|
449
|
+
const registration = this._focusPercentRegistration;
|
|
450
|
+
const manager = registration !== undefined ? registration.owner : this.focusPercentManager;
|
|
451
|
+
this.focusPercentManager = undefined;
|
|
452
|
+
if (manager) {
|
|
453
|
+
manager.unregisterFocusPercentCell?.(this);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
private clearFocusPercentValues(): void {
|
|
458
|
+
if (this.supportsFocusPercent) {
|
|
459
|
+
this.focusPercent = undefined;
|
|
460
|
+
if (this.viewFragment !== undefined) {
|
|
461
|
+
this.viewFragment.focusPercent = undefined;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (this.supportsRowFocusPercent) {
|
|
465
|
+
this.rowFocusPercent = undefined;
|
|
466
|
+
if (this.viewFragment !== undefined) {
|
|
467
|
+
this.viewFragment.rowFocusPercent = undefined;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
override onWillRelease(): void {
|
|
473
|
+
if (this.focusPercentManager !== undefined) {
|
|
474
|
+
this.detachFocusPercent();
|
|
475
|
+
} else if (this._focusPercentRegistration?.owner !== undefined) {
|
|
476
|
+
this.detachFocusPercent();
|
|
477
|
+
}
|
|
478
|
+
super.onWillRelease();
|
|
479
|
+
if (this.supportsFocusPercent) {
|
|
480
|
+
this.clearFocusPercentValues();
|
|
481
|
+
} else if (this.supportsRowFocusPercent) {
|
|
482
|
+
this.clearFocusPercentValues();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
367
486
|
protected override isSameContainer(row: IBaseCollectionViewRow): boolean {
|
|
368
487
|
if (!this.viewFragment) {
|
|
369
488
|
return true;
|
|
@@ -372,6 +491,16 @@ export class DynamicCell extends BaseCell {
|
|
|
372
491
|
}
|
|
373
492
|
|
|
374
493
|
override reset(): void {
|
|
494
|
+
if (this.focusPercentManager !== undefined) {
|
|
495
|
+
this.detachFocusPercent();
|
|
496
|
+
} else if (this._focusPercentRegistration?.owner !== undefined) {
|
|
497
|
+
this.detachFocusPercent();
|
|
498
|
+
}
|
|
499
|
+
if (this.supportsFocusPercent) {
|
|
500
|
+
this.clearFocusPercentValues();
|
|
501
|
+
} else if (this.supportsRowFocusPercent) {
|
|
502
|
+
this.clearFocusPercentValues();
|
|
503
|
+
}
|
|
375
504
|
let rowIndex = -1;
|
|
376
505
|
let rowId = '';
|
|
377
506
|
let cellIndex = -1;
|
|
@@ -423,6 +552,7 @@ export class DynamicCell extends BaseCell {
|
|
|
423
552
|
this.viewFragmentProvider.releaseFragment(this.viewFragment);
|
|
424
553
|
this.viewFragment = undefined;
|
|
425
554
|
this.currentStyle = '';
|
|
555
|
+
this.cacheFocusPercentCallbacks();
|
|
426
556
|
}
|
|
427
557
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
428
558
|
scrollJankLog('dynamic-cell-recycle-end', `rowIndex=${rowIndex} rowId=${rowId} cellIndex=${cellIndex} itemId=${itemId} hasFragment=${this.viewFragment !== undefined}`);
|
|
@@ -326,6 +326,7 @@ export class EPGProgramLayout extends BaseCollectionViewLayout {
|
|
|
326
326
|
for (const key in cellsToRemoveById) {
|
|
327
327
|
const cell = cellsToRemoveById[key];
|
|
328
328
|
delete this.cellsByIndex[key];
|
|
329
|
+
cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
|
|
329
330
|
cell.setVisible(false);
|
|
330
331
|
this.instancePool.release(cell);
|
|
331
332
|
}
|
|
@@ -195,6 +195,7 @@ export class GridRowLayout extends BaseCollectionViewLayout {
|
|
|
195
195
|
|
|
196
196
|
if (cellsToRemove.length > 0) {
|
|
197
197
|
for (const cell of cellsToRemove) {
|
|
198
|
+
cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
|
|
198
199
|
cell.setVisible(false);
|
|
199
200
|
this.instancePool.release(cell);
|
|
200
201
|
}
|
|
@@ -249,6 +249,7 @@ export class HorizontalRowLayout extends BaseCollectionViewLayout {
|
|
|
249
249
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
250
250
|
scrollJankLog('cell-flag-remove', `layout=horizontal rowIndex=${row.index} rowId=${row.id} cellIndex=${cell.index} itemId=${cell.item?.id ?? ''} reason=not-visible`);
|
|
251
251
|
}
|
|
252
|
+
cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
|
|
252
253
|
cell.setVisible(false);
|
|
253
254
|
this.instancePool.release(cell);
|
|
254
255
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
@@ -169,6 +169,7 @@ export class ListRowLayout extends BaseCollectionViewLayout {
|
|
|
169
169
|
|
|
170
170
|
if (cellsToRemove.length > 0) {
|
|
171
171
|
for (const cell of cellsToRemove) {
|
|
172
|
+
cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
|
|
172
173
|
cell.setVisible(false);
|
|
173
174
|
this.instancePool.release(cell);
|
|
174
175
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
<!-- Hosanna script imports for the UI -->
|
|
13
13
|
<!-- HOSANNA_SCRIPT_IMPORTS -->
|
|
14
14
|
<children>
|
|
15
|
-
|
|
15
|
+
<!-- Cover the initial scene until BaseApp establishes its black background. -->
|
|
16
|
+
<Rectangle id="hs_startupBackdrop" width="1920" height="1080" color="0x000000FF" />
|
|
16
17
|
</children>
|
|
17
18
|
</component>
|
|
@@ -90,16 +90,6 @@ export class ImageGeneratorCommands extends AbstractAsyncHandler {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
private ensureShapePatch(request: ShapePatchRequest): ImageGeneratorShapePatchResult {
|
|
93
|
-
if (!__ROKU__) {
|
|
94
|
-
return {
|
|
95
|
-
uri: request.uri,
|
|
96
|
-
cacheKey: request.cacheKey,
|
|
97
|
-
cacheHit: true,
|
|
98
|
-
generated: false,
|
|
99
|
-
success: true,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
93
|
const fs = CreateObject<ISGROFileSystem>('roFileSystem');
|
|
104
94
|
try {
|
|
105
95
|
this.ensureDirectory(fs, this.getDirectoryPath(request.uri));
|
|
@@ -133,16 +123,6 @@ export class ImageGeneratorCommands extends AbstractAsyncHandler {
|
|
|
133
123
|
}
|
|
134
124
|
|
|
135
125
|
private ensureShapeMask(request: ShapeMaskRequest): ImageGeneratorShapePatchResult {
|
|
136
|
-
if (!__ROKU__) {
|
|
137
|
-
return {
|
|
138
|
-
uri: request.uri,
|
|
139
|
-
cacheKey: request.cacheKey,
|
|
140
|
-
cacheHit: true,
|
|
141
|
-
generated: false,
|
|
142
|
-
success: true,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
126
|
const fs = CreateObject<ISGROFileSystem>('roFileSystem');
|
|
147
127
|
try {
|
|
148
128
|
this.ensureDirectory(fs, this.getDirectoryPath(request.uri));
|
|
@@ -584,6 +584,15 @@ export class BaseApp extends BaseView<ViewState> implements IObserver {
|
|
|
584
584
|
private prepareScene() {
|
|
585
585
|
this.scene.id = 'mainScene';
|
|
586
586
|
this.scene.backgroundColor = '#000000';
|
|
587
|
+
if (__ROKU__) {
|
|
588
|
+
// The XML backdrop covers frames before begin(). Hide it only after the
|
|
589
|
+
// scene background is black so it cannot cover the runtime app views.
|
|
590
|
+
// eslint-disable-next-line @hosanna-eslint/no-find-node-method
|
|
591
|
+
const startupBackdrop = this.scene.findNode('hs_startupBackdrop') as ISGNRectangle | undefined;
|
|
592
|
+
if (startupBackdrop) {
|
|
593
|
+
startupBackdrop.visible = false;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
587
596
|
this.renderer = this.scene;
|
|
588
597
|
GetGlobalAA().scene = this.scene;
|
|
589
598
|
// Cache the global node (shared across threads on Roku) so post-process and other async callbacks can access it
|
|
@@ -1986,8 +1995,6 @@ export class BaseApp extends BaseView<ViewState> implements IObserver {
|
|
|
1986
1995
|
* `theme.compiledShapes`, so shapes must be reloaded). Fragments created
|
|
1987
1996
|
* before a reload must be recreated to pick up new shape styles.
|
|
1988
1997
|
*
|
|
1989
|
-
* On Roku this waits for the imageGenerator task to pre-render each shape
|
|
1990
|
-
* to a nine-patch image; on other platforms it resolves immediately.
|
|
1991
1998
|
*/
|
|
1992
1999
|
loadShapes(): HsPromise<void> {
|
|
1993
2000
|
return loadShapesForAppConfig(this.appConfig);
|
|
@@ -2033,10 +2040,8 @@ export class BaseApp extends BaseView<ViewState> implements IObserver {
|
|
|
2033
2040
|
console.warn('[BaseApp] ⚠️ No valid "tasks" config found in build config, using default: { default: 1 }');
|
|
2034
2041
|
}
|
|
2035
2042
|
|
|
2036
|
-
if (
|
|
2037
|
-
|
|
2038
|
-
taskConfig.imageGenerator = 1;
|
|
2039
|
-
}
|
|
2043
|
+
if (taskConfig.imageGenerator === undefined) {
|
|
2044
|
+
taskConfig.imageGenerator = 1;
|
|
2040
2045
|
}
|
|
2041
2046
|
|
|
2042
2047
|
console.info('[BaseApp] Starting asyncCommandHandler with task config:', taskConfig);
|
|
@@ -105,8 +105,10 @@ export interface IConfigurationLoader {
|
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Shows a configuration error to the user with appropriate platform-specific UI.
|
|
108
|
+
* Without options the dialog has a single OK button. With options it shows the
|
|
109
|
+
* given buttons and, after closing, reports the selected button index.
|
|
108
110
|
*/
|
|
109
|
-
showConfigurationError(title: string, message: string): void;
|
|
111
|
+
showConfigurationError(title: string, message: string, options?: IConfigurationErrorOptions): void;
|
|
110
112
|
|
|
111
113
|
/**
|
|
112
114
|
* Gets the current environment (development, production, qa).
|
|
@@ -114,6 +116,11 @@ export interface IConfigurationLoader {
|
|
|
114
116
|
getEnvironment(): string;
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
export interface IConfigurationErrorOptions {
|
|
120
|
+
buttons?: string[];
|
|
121
|
+
onButtonSelected?: (index: number) => void;
|
|
122
|
+
}
|
|
123
|
+
|
|
117
124
|
/**
|
|
118
125
|
* ConfigurationLoader handles loading and validation of configuration files
|
|
119
126
|
* with proper error handling and user feedback.
|
|
@@ -427,13 +434,13 @@ Troubleshooting:
|
|
|
427
434
|
/**
|
|
428
435
|
* Shows a configuration error with platform-appropriate UI.
|
|
429
436
|
*/
|
|
430
|
-
showConfigurationError(title: string, message: string): void {
|
|
437
|
+
showConfigurationError(title: string, message: string, options?: IConfigurationErrorOptions): void {
|
|
431
438
|
console.error(`FATAL CONFIGURATION ERROR: ${title}`);
|
|
432
439
|
console.error(message);
|
|
433
440
|
const dialog = CreateObject<ISGNStandardMessageDialog>('roSGNode', 'StandardMessageDialog');
|
|
434
441
|
dialog.title = title;
|
|
435
442
|
dialog.message = [message];
|
|
436
|
-
dialog.buttons = ["OK"];
|
|
443
|
+
dialog.buttons = options?.buttons && options.buttons.length > 0 ? options.buttons : ["OK"];
|
|
437
444
|
const globalAA = GetGlobalAA();
|
|
438
445
|
const scene = globalAA?.scene;
|
|
439
446
|
if (scene) {
|
|
@@ -444,6 +451,7 @@ Troubleshooting:
|
|
|
444
451
|
scene.dialog = null;
|
|
445
452
|
dialog.close = true;
|
|
446
453
|
scene.setFocus(true);
|
|
454
|
+
if (options?.onButtonSelected) options.onButtonSelected(dialog.buttonSelected as number);
|
|
447
455
|
});
|
|
448
456
|
} else {
|
|
449
457
|
console.error('Scene not found, Must be running from backgroud task. cannot show configuration error');
|
|
@@ -18,8 +18,6 @@ import {
|
|
|
18
18
|
* @returns The value at the specified path, or the default value if not found.
|
|
19
19
|
*/
|
|
20
20
|
export function getPath<T>(content: unknown, path: string, defaultValue: unknown = undefined, disableIndexing: boolean = false): T {
|
|
21
|
-
//FIXME - on roku, this function does not work!
|
|
22
|
-
// hs_native_roku(`return hs_getPath(content, path, defaultValue, disableIndexing)`)
|
|
23
21
|
if (!path) {
|
|
24
22
|
return defaultValue as T;
|
|
25
23
|
}
|
|
@@ -38,18 +36,36 @@ export function getPath<T>(content: unknown, path: string, defaultValue: unknown
|
|
|
38
36
|
// eslint-disable-next-line @hosanna-eslint/no-unsafe-number-parsing
|
|
39
37
|
part = Array.isArray(part) ? part[Number(key)] : undefined;
|
|
40
38
|
} else {
|
|
41
|
-
// Check if current part has the key directly
|
|
42
39
|
const partRecord = part as Record<string, unknown>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//
|
|
40
|
+
if (__ROKU__) {
|
|
41
|
+
if (typeof part !== 'object' || Array.isArray(part)) {
|
|
42
|
+
return defaultValue as T;
|
|
43
|
+
}
|
|
44
|
+
// AA lookup is case-insensitive; dot assignment can change enumerated key casing.
|
|
45
|
+
// hasOwnProperty lowers to doesExist on Roku, including shadowed data keys.
|
|
46
|
+
if (partRecord.hasOwnProperty(key)) {
|
|
47
|
+
part = partRecord[key];
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
48
50
|
const concatenatedKey = parts.slice(i).join('.');
|
|
49
|
-
if (
|
|
51
|
+
if (partRecord.hasOwnProperty(concatenatedKey)) {
|
|
50
52
|
return partRecord[concatenatedKey] as T;
|
|
51
53
|
}
|
|
52
|
-
return defaultValue as T;
|
|
54
|
+
return defaultValue as T;
|
|
55
|
+
}
|
|
56
|
+
if (!__ROKU__) {
|
|
57
|
+
// Preserve enumerable-own lookup for browser records, including shadowed helpers.
|
|
58
|
+
const partKeys = Object.keys(partRecord);
|
|
59
|
+
if (partKeys.includes(key)) {
|
|
60
|
+
part = partRecord[key];
|
|
61
|
+
} else {
|
|
62
|
+
// Try concatenated key for remaining parts if direct access fails
|
|
63
|
+
const concatenatedKey = parts.slice(i).join('.');
|
|
64
|
+
if (partKeys.includes(concatenatedKey)) {
|
|
65
|
+
return partRecord[concatenatedKey] as T;
|
|
66
|
+
}
|
|
67
|
+
return defaultValue as T; // Key does not exist at this level
|
|
68
|
+
}
|
|
53
69
|
}
|
|
54
70
|
}
|
|
55
71
|
}
|