@tantawowa/hosanna-ui 2.0.4 → 2.1.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 +10 -10
- package/package.json +1 -1
- 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-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/shapes/ShapeLoader.ts +22 -27
- package/src/hosanna-ui/views/lib/BaseView.ts +28 -15
package/dist-manifest.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"artifact": "npm-sdk",
|
|
4
4
|
"packageName": "@tantawowa/hosanna-ui",
|
|
5
|
-
"version": "2.0
|
|
6
|
-
"sourceCommit": "
|
|
5
|
+
"version": "2.1.0",
|
|
6
|
+
"sourceCommit": "08f3b524c1d66291f8c4d634185eb8bba335a3dc",
|
|
7
7
|
"files": [
|
|
8
8
|
{
|
|
9
9
|
"path": "LICENSE",
|
|
@@ -359,7 +359,7 @@
|
|
|
359
359
|
},
|
|
360
360
|
{
|
|
361
361
|
"path": "src/hosanna-bridge-targets/web/brs/WebRoBitmap.ts",
|
|
362
|
-
"sha256": "
|
|
362
|
+
"sha256": "b4be6ac206646f3cab6d8170b6115ec844577fb3a621fbf81b3dc3b1ad9b8b20"
|
|
363
363
|
},
|
|
364
364
|
{
|
|
365
365
|
"path": "src/hosanna-bridge-targets/web/brs/WebRoByteArray.ts",
|
|
@@ -887,7 +887,7 @@
|
|
|
887
887
|
},
|
|
888
888
|
{
|
|
889
889
|
"path": "src/hosanna-bridge-targets/web/sg/WebSGPoster.ts",
|
|
890
|
-
"sha256": "
|
|
890
|
+
"sha256": "8690f7310f0f3ee124530ec016f82a252aa408da403b514566b2ddfdd2f893e1"
|
|
891
891
|
},
|
|
892
892
|
{
|
|
893
893
|
"path": "src/hosanna-bridge-targets/web/sg/WebSGRectangle.ts",
|
|
@@ -1843,7 +1843,7 @@
|
|
|
1843
1843
|
},
|
|
1844
1844
|
{
|
|
1845
1845
|
"path": "src/hosanna-ui/app-roku/HosannaApp.xml",
|
|
1846
|
-
"sha256": "
|
|
1846
|
+
"sha256": "027475b9fe1446b65f6961e690d150f3be988cac26be6578bf5cbc770cf5098f"
|
|
1847
1847
|
},
|
|
1848
1848
|
{
|
|
1849
1849
|
"path": "src/hosanna-ui/app-roku/HosannaMainThreadScene.xml",
|
|
@@ -1899,7 +1899,7 @@
|
|
|
1899
1899
|
},
|
|
1900
1900
|
{
|
|
1901
1901
|
"path": "src/hosanna-ui/async/ImageGeneratorCommands.ts",
|
|
1902
|
-
"sha256": "
|
|
1902
|
+
"sha256": "2bb5bef67aaafcb6877d3a43b790490d418659c8ca2e4db48b7cbeb25d58f7e6"
|
|
1903
1903
|
},
|
|
1904
1904
|
{
|
|
1905
1905
|
"path": "src/hosanna-ui/async/LivePlaylistCommands.ts",
|
|
@@ -1943,7 +1943,7 @@
|
|
|
1943
1943
|
},
|
|
1944
1944
|
{
|
|
1945
1945
|
"path": "src/hosanna-ui/lib/BaseApp.ts",
|
|
1946
|
-
"sha256": "
|
|
1946
|
+
"sha256": "b300ace1436dcfc41f7bb15e2d9ec5ebbf85f5c594e2967742311279a5968e2f"
|
|
1947
1947
|
},
|
|
1948
1948
|
{
|
|
1949
1949
|
"path": "src/hosanna-ui/lib/BuildConfigRuntimePath.ts",
|
|
@@ -1951,7 +1951,7 @@
|
|
|
1951
1951
|
},
|
|
1952
1952
|
{
|
|
1953
1953
|
"path": "src/hosanna-ui/lib/ConfigurationLoader.ts",
|
|
1954
|
-
"sha256": "
|
|
1954
|
+
"sha256": "be039919478eeb7eba4d686637731855c693676c18c517ff6700a9610029e643"
|
|
1955
1955
|
},
|
|
1956
1956
|
{
|
|
1957
1957
|
"path": "src/hosanna-ui/lib/ConfigurationValidator.ts",
|
|
@@ -2343,7 +2343,7 @@
|
|
|
2343
2343
|
},
|
|
2344
2344
|
{
|
|
2345
2345
|
"path": "src/hosanna-ui/lib/shapes/ShapeLoader.ts",
|
|
2346
|
-
"sha256": "
|
|
2346
|
+
"sha256": "2ccc633a272f9efdacb5e7e52a7c5d7b2bf4db2d7131a9900542f68b8143146f"
|
|
2347
2347
|
},
|
|
2348
2348
|
{
|
|
2349
2349
|
"path": "src/hosanna-ui/lib/shapes/ShapeMaskResolver.ts",
|
|
@@ -2631,7 +2631,7 @@
|
|
|
2631
2631
|
},
|
|
2632
2632
|
{
|
|
2633
2633
|
"path": "src/hosanna-ui/views/lib/BaseView.ts",
|
|
2634
|
-
"sha256": "
|
|
2634
|
+
"sha256": "b3ceb393e817c371610c26b0e54c1d886dafd637828f5c31fa51f6781fd78cf1"
|
|
2635
2635
|
},
|
|
2636
2636
|
{
|
|
2637
2637
|
"path": "src/hosanna-ui/views/lib/BuildConfig.ts",
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WebDraw2D, WebDrawableSource } from './draw2d/WebDraw2D';
|
|
2
2
|
import { WebBrsComponent } from './WebBrsComponent';
|
|
3
3
|
import { WebRoFont } from './WebRoFont';
|
|
4
|
+
import { WebRoByteArray } from './WebRoByteArray';
|
|
4
5
|
|
|
5
6
|
interface BitmapSize {
|
|
6
7
|
width: number;
|
|
@@ -66,6 +67,19 @@ export class WebRoBitmap extends WebBrsComponent {
|
|
|
66
67
|
return this.height;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
GetPng(x: number, y: number, width: number, height: number): WebRoByteArray {
|
|
71
|
+
const canvas = document.createElement('canvas');
|
|
72
|
+
canvas.width = width;
|
|
73
|
+
canvas.height = height;
|
|
74
|
+
const context = canvas.getContext('2d');
|
|
75
|
+
if (!context) {
|
|
76
|
+
throw new Error('WebRoBitmap.GetPng requires a 2D canvas context');
|
|
77
|
+
}
|
|
78
|
+
context.drawImage(this.canvas, x, y, width, height, 0, 0, width, height);
|
|
79
|
+
const encoded = canvas.toDataURL('image/png').split(',')[1];
|
|
80
|
+
return new WebRoByteArray(Uint8Array.from(atob(encoded), character => character.charCodeAt(0)));
|
|
81
|
+
}
|
|
82
|
+
|
|
69
83
|
getCanvas(): CanvasImageSource {
|
|
70
84
|
return this.canvas;
|
|
71
85
|
}
|
|
@@ -285,7 +285,7 @@ export class WebSGPoster extends WebSGGroup implements ISGNPoster {
|
|
|
285
285
|
|
|
286
286
|
// Detect if content-related fields changed since last render
|
|
287
287
|
const resolvedUri = resolveImageUri(this.uri);
|
|
288
|
-
const ninePatch = isNinePatch(resolvedUri);
|
|
288
|
+
const ninePatch = isNinePatch(this.uri) || isNinePatch(resolvedUri);
|
|
289
289
|
const contentChanged = this._contentDirty ||
|
|
290
290
|
resolvedUri !== this._lastRenderedUri ||
|
|
291
291
|
this.blendColor !== this._lastRenderedBlendColor ||
|
|
@@ -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');
|
|
@@ -109,12 +109,6 @@ function validateMaskEntry(styleKey: string, entry: ShapeStyleEntry): void {
|
|
|
109
109
|
/**
|
|
110
110
|
* Compiles `theme.shapes` into `theme.compiledShapes`.
|
|
111
111
|
*
|
|
112
|
-
* On Roku each entry is pre-rendered to a nine-patch image by the
|
|
113
|
-
* imageGenerator task and compiles to `{ uri, translationOffset, sizeOffset }`.
|
|
114
|
-
* On all other platforms shapes draw natively, so each entry compiles to its
|
|
115
|
-
* resolved shape fields and no task work is done. Build-generated image
|
|
116
|
-
* metadata is retained so Image consumers can use the same packaged assets.
|
|
117
|
-
*
|
|
118
112
|
* Safe to call at any time. Must be re-run after a config reload
|
|
119
113
|
* (`setConfig` replaces styles wholesale, wiping `theme.compiledShapes`);
|
|
120
114
|
* fragments created before that re-run must be recreated to pick up changes.
|
|
@@ -130,27 +124,6 @@ export function loadShapesForAppConfig(appConfig: IAppConfig): HsPromise<void> {
|
|
|
130
124
|
|
|
131
125
|
const resolverOptions = getResolverOptions(appConfig, shapes);
|
|
132
126
|
|
|
133
|
-
if (!__ROKU__) {
|
|
134
|
-
const supplied = appConfig.get<Record<string, CompiledShape>>(THEME_COMPILED_SHAPES_KEY, {});
|
|
135
|
-
const compiled: Record<string, CompiledShape> = { ...supplied };
|
|
136
|
-
for (const styleKey in shapes) {
|
|
137
|
-
validateMaskEntry(styleKey, shapes[styleKey]);
|
|
138
|
-
const spec = resolveShapeSpecFields(shapes[styleKey], resolverOptions);
|
|
139
|
-
compiled[styleKey] = {
|
|
140
|
-
...supplied[styleKey],
|
|
141
|
-
kind: spec.kind,
|
|
142
|
-
fillColor: spec.fillColor,
|
|
143
|
-
cornerRadius: spec.cornerRadius,
|
|
144
|
-
strokeColor: spec.strokeColor,
|
|
145
|
-
strokeWidth: spec.strokeWidth,
|
|
146
|
-
shadows: spec.shadows,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
storeCompiledShapes(appConfig, compiled);
|
|
150
|
-
resolve();
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
127
|
const requests: Record<string, ShapePatchRequest> = {};
|
|
155
128
|
const supplied = appConfig.get<Record<string, CompiledShape>>(THEME_COMPILED_SHAPES_KEY, {});
|
|
156
129
|
const compiled: Record<string, CompiledShape> = { ...supplied };
|
|
@@ -203,11 +176,33 @@ export function loadShapesForAppConfig(appConfig: IAppConfig): HsPromise<void> {
|
|
|
203
176
|
requestCount++;
|
|
204
177
|
}
|
|
205
178
|
|
|
179
|
+
if (!__ROKU__) {
|
|
180
|
+
for (const styleKey in shapes) {
|
|
181
|
+
const spec = resolveShapeSpecFields(shapes[styleKey], resolverOptions);
|
|
182
|
+
compiled[styleKey] = {
|
|
183
|
+
...compiled[styleKey],
|
|
184
|
+
kind: spec.kind,
|
|
185
|
+
fillColor: spec.fillColor,
|
|
186
|
+
cornerRadius: spec.cornerRadius,
|
|
187
|
+
strokeColor: spec.strokeColor,
|
|
188
|
+
strokeWidth: spec.strokeWidth,
|
|
189
|
+
shadows: spec.shadows,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
206
194
|
// uris and offsets are deterministic from the spec, so the compiled map is
|
|
207
195
|
// valid before generation completes; the promise gates on the task so
|
|
208
196
|
// callers can await the images existing on disk.
|
|
209
197
|
storeCompiledShapes(appConfig, compiled);
|
|
210
198
|
|
|
199
|
+
if (!__ROKU__) {
|
|
200
|
+
if (requestCount === 0) {
|
|
201
|
+
resolve();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
211
206
|
const compileState: {
|
|
212
207
|
settled: boolean;
|
|
213
208
|
timeoutHandle?: ReturnType<typeof setTimeout>;
|
|
@@ -217,6 +217,8 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
217
217
|
// passed in through view state belongs to the caller and is only suspended.
|
|
218
218
|
private disposesViewModelOnUnmount = true;
|
|
219
219
|
private hasStartedViewModel = false;
|
|
220
|
+
private isViewModelSuspended = false;
|
|
221
|
+
private hasReleasedViewModel = false;
|
|
220
222
|
private boundViewModelHid = '';
|
|
221
223
|
private isApplyingViewModelFocus = false;
|
|
222
224
|
private lastReportedViewModelFocusId = '';
|
|
@@ -2808,6 +2810,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
2808
2810
|
}
|
|
2809
2811
|
|
|
2810
2812
|
onDidRemoveFromAggregateView(view: IAggregateView): void {
|
|
2813
|
+
this.releaseViewModel();
|
|
2811
2814
|
if (this.eventHandlers['onDidRemoveFromAggregateView']) {
|
|
2812
2815
|
this.eventHandlers['onDidRemoveFromAggregateView'](view);
|
|
2813
2816
|
}
|
|
@@ -2849,6 +2852,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
2849
2852
|
const vm = this.viewModel;
|
|
2850
2853
|
if (vm) {
|
|
2851
2854
|
this.bindViewModel();
|
|
2855
|
+
this.isViewModelSuspended = false;
|
|
2852
2856
|
if (this.hasStartedViewModel) {
|
|
2853
2857
|
vm.resume(this.getViewModelContext());
|
|
2854
2858
|
} else {
|
|
@@ -2867,9 +2871,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
2867
2871
|
if (this.eventHandlers['onDisappear']) {
|
|
2868
2872
|
this.eventHandlers['onDisappear']();
|
|
2869
2873
|
}
|
|
2870
|
-
|
|
2871
|
-
this.viewModel.suspend();
|
|
2872
|
-
}
|
|
2874
|
+
this.suspendViewModel();
|
|
2873
2875
|
}
|
|
2874
2876
|
|
|
2875
2877
|
setShowOnScreen(shown: boolean) {
|
|
@@ -3450,6 +3452,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3450
3452
|
if (!vm) {
|
|
3451
3453
|
return;
|
|
3452
3454
|
}
|
|
3455
|
+
this.hasReleasedViewModel = false;
|
|
3453
3456
|
vm.addObserver('__internalState', this, (field) => {
|
|
3454
3457
|
const current = this.viewModel;
|
|
3455
3458
|
if (!current) {
|
|
@@ -3478,13 +3481,15 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3478
3481
|
}
|
|
3479
3482
|
if (previous) {
|
|
3480
3483
|
previous.removeObservers(this);
|
|
3481
|
-
if (this.disposesViewModelOnUnmount) {
|
|
3484
|
+
if (this.disposesViewModelOnUnmount && !previous.isDisposed) {
|
|
3482
3485
|
previous.dispose();
|
|
3483
3486
|
}
|
|
3484
3487
|
}
|
|
3485
3488
|
this.viewModel = vm;
|
|
3486
3489
|
this.disposesViewModelOnUnmount = false;
|
|
3487
3490
|
this.hasStartedViewModel = false;
|
|
3491
|
+
this.isViewModelSuspended = false;
|
|
3492
|
+
this.hasReleasedViewModel = false;
|
|
3488
3493
|
this.boundViewModelHid = '';
|
|
3489
3494
|
this.lastReportedViewModelFocusId = '';
|
|
3490
3495
|
this.pendingViewModelFocus = '';
|
|
@@ -3494,39 +3499,47 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3494
3499
|
/** The view is unmounted: its own model is finished; a parent's model is only paused. */
|
|
3495
3500
|
private releaseViewModel(): void {
|
|
3496
3501
|
const vm = this.viewModel;
|
|
3497
|
-
if (!vm) {
|
|
3502
|
+
if (!vm || this.hasReleasedViewModel) {
|
|
3498
3503
|
return;
|
|
3499
3504
|
}
|
|
3505
|
+
this.hasReleasedViewModel = true;
|
|
3500
3506
|
vm.removeObservers(this);
|
|
3501
3507
|
this.boundViewModelHid = '';
|
|
3502
3508
|
this.lastReportedViewModelFocusId = '';
|
|
3503
3509
|
this.pendingViewModelFocus = '';
|
|
3504
3510
|
if (!this.disposesViewModelOnUnmount) {
|
|
3505
|
-
|
|
3506
|
-
vm.suspend();
|
|
3507
|
-
}
|
|
3511
|
+
this.suspendViewModel();
|
|
3508
3512
|
return;
|
|
3509
3513
|
}
|
|
3510
|
-
// Dispose only when a fresh model can take its place, so a view that is
|
|
3511
|
-
// mounted again never holds a dead one.
|
|
3512
3514
|
const replacement = this.createViewModel();
|
|
3513
|
-
|
|
3515
|
+
this.viewModel = replacement;
|
|
3516
|
+
this.hasStartedViewModel = false;
|
|
3517
|
+
this.isViewModelSuspended = false;
|
|
3518
|
+
if (!vm.isDisposed) {
|
|
3514
3519
|
vm.dispose();
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
private suspendViewModel(): void {
|
|
3524
|
+
const vm = this.viewModel;
|
|
3525
|
+
if (vm && this.hasStartedViewModel && !this.isViewModelSuspended && !vm.isDisposed) {
|
|
3526
|
+
this.isViewModelSuspended = true;
|
|
3518
3527
|
vm.suspend();
|
|
3519
3528
|
}
|
|
3520
3529
|
}
|
|
3521
3530
|
|
|
3522
3531
|
/** The view instance is being reused for another screen: drop a parent's model and start clean. */
|
|
3523
3532
|
private recycleViewModel(): void {
|
|
3533
|
+
if (this.hasStartedViewModel || this.boundViewModelHid !== '' || this.viewModel?.isDisposed) {
|
|
3534
|
+
this.releaseViewModel();
|
|
3535
|
+
}
|
|
3524
3536
|
if (!this.disposesViewModelOnUnmount) {
|
|
3525
|
-
this.viewModel?.removeObservers(this);
|
|
3526
3537
|
this.viewModel = this.createViewModel();
|
|
3527
3538
|
this.disposesViewModelOnUnmount = true;
|
|
3528
3539
|
}
|
|
3529
3540
|
this.hasStartedViewModel = false;
|
|
3541
|
+
this.isViewModelSuspended = false;
|
|
3542
|
+
this.hasReleasedViewModel = false;
|
|
3530
3543
|
this.boundViewModelHid = '';
|
|
3531
3544
|
this.lastReportedViewModelFocusId = '';
|
|
3532
3545
|
this.pendingViewModelFocus = '';
|