@tantawowa/hosanna-ui 2.0.1 → 2.0.3
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 +23 -7
- package/package.json +1 -1
- package/src/hosanna-bridge-targets/web/assets/fonts/NotoSans_Condensed-Bold.ttf +0 -0
- package/src/hosanna-bridge-targets/web/assets/fonts/NotoSans_Condensed-Regular.ttf +0 -0
- package/src/hosanna-bridge-targets/web/assets/fonts/OFL.txt +93 -0
- package/src/hosanna-bridge-targets/web/assets/fonts/README.md +5 -0
- package/src/hosanna-bridge-targets/web/lib/WebFontService.ts +9 -1
- package/src/hosanna-bridge-targets/web/sg/ComponentLibraryArchive.ts +1 -1
- package/src/hosanna-game/runtime/GameRuntime.ts +8 -5
- package/src/hosanna-ui/lib/BaseApp.ts +6 -18
- package/src/hosanna-ui/views/lib/BaseView.ts +90 -2
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.0.3",
|
|
6
|
+
"sourceCommit": "ed9d9afbfe2df5dcf5e71b5e1e34235c954684f9",
|
|
7
7
|
"files": [
|
|
8
8
|
{
|
|
9
9
|
"path": "LICENSE",
|
|
@@ -309,6 +309,22 @@
|
|
|
309
309
|
"path": "src/hosanna-bridge-targets/roku/polyfills.roku.ts",
|
|
310
310
|
"sha256": "3417b34248ff4f6cc374fe3513f4480e95ceaf44a9178629b2350ae246618ac5"
|
|
311
311
|
},
|
|
312
|
+
{
|
|
313
|
+
"path": "src/hosanna-bridge-targets/web/assets/fonts/NotoSans_Condensed-Bold.ttf",
|
|
314
|
+
"sha256": "0e33e939db9dd0d897453f9d01088c4f258b9888eff1d24a6e65d18b2a427485"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"path": "src/hosanna-bridge-targets/web/assets/fonts/NotoSans_Condensed-Regular.ttf",
|
|
318
|
+
"sha256": "4e326cc003d76d2ab8fafefdda2cb8d4558beb8279ad763b9acd6309ff2d70bc"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"path": "src/hosanna-bridge-targets/web/assets/fonts/OFL.txt",
|
|
322
|
+
"sha256": "e2e177a32561584d4fc13aaa3cd8e53758a12910f013fe9ca125419111722029"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"path": "src/hosanna-bridge-targets/web/assets/fonts/README.md",
|
|
326
|
+
"sha256": "6a8a29efae82941fe3ffc909f2daf6cba2d5c238494f2fbdb78da739ed38b41c"
|
|
327
|
+
},
|
|
312
328
|
{
|
|
313
329
|
"path": "src/hosanna-bridge-targets/web/brs/VirtualBrsComponent.ts",
|
|
314
330
|
"sha256": "616c8deab4de69267ea015679ff0e2eb2be8b9c5c627e5c888891ab724ce00ae"
|
|
@@ -555,7 +571,7 @@
|
|
|
555
571
|
},
|
|
556
572
|
{
|
|
557
573
|
"path": "src/hosanna-bridge-targets/web/lib/WebFontService.ts",
|
|
558
|
-
"sha256": "
|
|
574
|
+
"sha256": "b4eba0dca29eb6fd9e074d8d4fd5bac80684218ba6270cf897f75167705e82b9"
|
|
559
575
|
},
|
|
560
576
|
{
|
|
561
577
|
"path": "src/hosanna-bridge-targets/web/lib/WebOrientationPlatformAdapter.ts",
|
|
@@ -739,7 +755,7 @@
|
|
|
739
755
|
},
|
|
740
756
|
{
|
|
741
757
|
"path": "src/hosanna-bridge-targets/web/sg/ComponentLibraryArchive.ts",
|
|
742
|
-
"sha256": "
|
|
758
|
+
"sha256": "717ed04ad996143f07ad82bb29035f71030b0f96a49fc84cd95b01cc944e1c6b"
|
|
743
759
|
},
|
|
744
760
|
{
|
|
745
761
|
"path": "src/hosanna-bridge-targets/web/sg/HsShape.ts",
|
|
@@ -1447,7 +1463,7 @@
|
|
|
1447
1463
|
},
|
|
1448
1464
|
{
|
|
1449
1465
|
"path": "src/hosanna-game/runtime/GameRuntime.ts",
|
|
1450
|
-
"sha256": "
|
|
1466
|
+
"sha256": "a198eeef1e4fa5701f58fc6c99b61315158397e4905d993d72823f4b563fa076"
|
|
1451
1467
|
},
|
|
1452
1468
|
{
|
|
1453
1469
|
"path": "src/hosanna-game/runtime/GameRuntimeServices.ts",
|
|
@@ -1931,7 +1947,7 @@
|
|
|
1931
1947
|
},
|
|
1932
1948
|
{
|
|
1933
1949
|
"path": "src/hosanna-ui/lib/BaseApp.ts",
|
|
1934
|
-
"sha256": "
|
|
1950
|
+
"sha256": "2d8f750e4d2ede4addae1464c22f2420e1415c3e4d6d5662c14bc60b70727d74"
|
|
1935
1951
|
},
|
|
1936
1952
|
{
|
|
1937
1953
|
"path": "src/hosanna-ui/lib/BuildConfigRuntimePath.ts",
|
|
@@ -2619,7 +2635,7 @@
|
|
|
2619
2635
|
},
|
|
2620
2636
|
{
|
|
2621
2637
|
"path": "src/hosanna-ui/views/lib/BaseView.ts",
|
|
2622
|
-
"sha256": "
|
|
2638
|
+
"sha256": "fc014923ab461492c2dc8f364c286821c8b212b2bb9766ba676cf71ae87dfc23"
|
|
2623
2639
|
},
|
|
2624
2640
|
{
|
|
2625
2641
|
"path": "src/hosanna-ui/views/lib/BuildConfig.ts",
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Browser system fonts
|
|
2
|
+
|
|
3
|
+
These unmodified Noto Sans Condensed files provide the browser emulator’s regular and bold system fonts. WebFontService resolves them from the installed SDK; Vite emits them as application build assets. Roku uses its native system fonts.
|
|
4
|
+
|
|
5
|
+
The files retain their original font metadata and are licensed under the SIL Open Font License 1.1 in OFL.txt. Source and copyright holder: https://github.com/notofonts/latin-greek-cyrillic.
|
|
@@ -107,7 +107,15 @@ export function registerFont(fontName: string, fontUrl: string): Promise<void> {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
const normalizedFontUrl = normalizePkgUri(fontUrl);
|
|
110
|
-
|
|
110
|
+
// Keep the public system-font identity while loading its bytes from the SDK.
|
|
111
|
+
// Vite serves these relative assets in development and emits them for production.
|
|
112
|
+
let assetUrl = normalizedFontUrl;
|
|
113
|
+
if (normalizedFontUrl === normalizePkgUri(SystemDefaultRegularFontUri)) {
|
|
114
|
+
assetUrl = new URL('../assets/fonts/NotoSans_Condensed-Regular.ttf', import.meta.url).href;
|
|
115
|
+
} else if (normalizedFontUrl === normalizePkgUri(SystemDefaultBoldFontUri)) {
|
|
116
|
+
assetUrl = new URL('../assets/fonts/NotoSans_Condensed-Bold.ttf', import.meta.url).href;
|
|
117
|
+
}
|
|
118
|
+
const fontFace = new FontFace(normalizedFontName, `url(${assetUrl})`);
|
|
111
119
|
return fontFace
|
|
112
120
|
.load()
|
|
113
121
|
.then((loadedFontFace) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// hs:exclude-from-platform roku
|
|
2
2
|
import { unzipSync, strFromU8 } from 'fflate';
|
|
3
|
-
import
|
|
3
|
+
import crc32 from 'crc/calculators/crc32';
|
|
4
4
|
import { AppUtils } from '@hs-src/hosanna-bridge-core/AppUtils';
|
|
5
5
|
import { createPortPromise } from '@hs-src/hosanna-bridge-core/Promises';
|
|
6
6
|
import type { IHosannaFileSystem } from '@hs-src/hosanna-bridge-core/api';
|
|
@@ -202,12 +202,15 @@ export class GameRuntime {
|
|
|
202
202
|
GameCollisionManager.renderDebugColliders(this.options.screen);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
if (
|
|
208
|
-
this.
|
|
205
|
+
if (!__ROKU__) {
|
|
206
|
+
// Present is a browser hook; probing it on native roScreen raises an error.
|
|
207
|
+
if (this.options.screen.Present) {
|
|
208
|
+
this.options.screen.Present();
|
|
209
|
+
if (__TELEMETRY__) {
|
|
210
|
+
this.updatePerformanceStats(frameDeltaMs, frameStartMs, updateEndMs, renderEndMs, this.now());
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
209
213
|
}
|
|
210
|
-
return true;
|
|
211
214
|
}
|
|
212
215
|
this.options.screen.SwapBuffers();
|
|
213
216
|
if (__TELEMETRY__) {
|
|
@@ -482,6 +482,11 @@ export class BaseApp extends BaseView<ViewState> implements IObserver {
|
|
|
482
482
|
this.begin();
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
+
/** BaseApp creates the container that its BaseView services depend on. */
|
|
486
|
+
protected override shouldDeferViewInitialization(): boolean {
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
|
|
485
490
|
/**
|
|
486
491
|
* Begins the application launch sequence.
|
|
487
492
|
* Initializes scene, IoC, views, and starts the main loop.
|
|
@@ -500,6 +505,7 @@ export class BaseApp extends BaseView<ViewState> implements IObserver {
|
|
|
500
505
|
// Emulated web: call directly since hs_native_roku is a no-op
|
|
501
506
|
this.assignBaseIOCServices();
|
|
502
507
|
}
|
|
508
|
+
this.initializeViewNotifications();
|
|
503
509
|
this.beforeLaunch();
|
|
504
510
|
// CRITICAL: Resolve IoC dependencies BEFORE creating views
|
|
505
511
|
// Views (like DialogManagerView) extend BaseView which uses @inject() decorators
|
|
@@ -539,24 +545,6 @@ export class BaseApp extends BaseView<ViewState> implements IObserver {
|
|
|
539
545
|
});
|
|
540
546
|
}
|
|
541
547
|
|
|
542
|
-
/**
|
|
543
|
-
* Assigns base IoC services to the app instance.
|
|
544
|
-
* Used as a workaround for static-only injection on Roku.
|
|
545
|
-
*/
|
|
546
|
-
private assignBaseIOCServices() {
|
|
547
|
-
//On Roku, @inject is static only, not lazy, so if something does not exist at instanatiation time, we have to assign it later.
|
|
548
|
-
//This is a workaround for that.
|
|
549
|
-
//Where we have to assign anything that was injected before we made the IOC container.
|
|
550
|
-
const platform = AppUtils.getPlatform();
|
|
551
|
-
this.nodePool = AppUtils.resolve('nodePool');
|
|
552
|
-
this.appConfig = AppUtils.resolve('appConfig');
|
|
553
|
-
this.viewManager = AppUtils.resolve('viewManager');
|
|
554
|
-
this.viewBuilder = AppUtils.resolve('viewBuilder');
|
|
555
|
-
this.focusManager = AppUtils.resolve('focusManager');
|
|
556
|
-
this.instancePool = AppUtils.resolve('instancePool');
|
|
557
|
-
console.info(`Assigned base IOC services to BaseApp (platform: ${platform})`);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
548
|
/*******************************************************************
|
|
561
549
|
* Launch initialization
|
|
562
550
|
*******************************************************************/
|
|
@@ -168,11 +168,17 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
168
168
|
_cacheKey = '';
|
|
169
169
|
|
|
170
170
|
// private nodePool: INodePool = new NodePool();
|
|
171
|
+
// hs:exclude-from-platform roku
|
|
171
172
|
@inject() nodePool!: INodePool;
|
|
173
|
+
// hs:exclude-from-platform roku
|
|
172
174
|
@inject() appConfig!: IAppConfig;
|
|
175
|
+
// hs:exclude-from-platform roku
|
|
173
176
|
@inject() protected viewManager!: IViewManager;
|
|
177
|
+
// hs:exclude-from-platform roku
|
|
174
178
|
@inject() protected viewBuilder!: ViewBuilder;
|
|
179
|
+
// hs:exclude-from-platform roku
|
|
175
180
|
@inject() protected focusManager!: IFocusManager;
|
|
181
|
+
// hs:exclude-from-platform roku
|
|
176
182
|
@inject() instancePool!: IInstancePool;
|
|
177
183
|
|
|
178
184
|
private _renderer: R | undefined;
|
|
@@ -214,6 +220,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
214
220
|
private boundViewModelHid = '';
|
|
215
221
|
private isApplyingViewModelFocus = false;
|
|
216
222
|
private lastReportedViewModelFocusId = '';
|
|
223
|
+
private pendingViewModelFocus = '';
|
|
217
224
|
|
|
218
225
|
//these parent child relationships refer to the view tree
|
|
219
226
|
parent?: IHosannaView<ViewState> = undefined;
|
|
@@ -409,6 +416,31 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
409
416
|
constructor() {
|
|
410
417
|
// hs:exclude-from-platform roku
|
|
411
418
|
this._hid = `${getUniqueViewId()}`;
|
|
419
|
+
if (!this.shouldDeferViewInitialization()) {
|
|
420
|
+
if (__ROKU__) {
|
|
421
|
+
this.assignBaseIOCServices();
|
|
422
|
+
}
|
|
423
|
+
this.initializeViewNotifications();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** The app overrides this while it creates the container used by all views. */
|
|
428
|
+
protected shouldDeferViewInitialization(): boolean {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Resolve view services after the app has created its IoC container. */
|
|
433
|
+
protected assignBaseIOCServices(): void {
|
|
434
|
+
this.nodePool = AppUtils.resolve('nodePool');
|
|
435
|
+
this.appConfig = AppUtils.resolve('appConfig');
|
|
436
|
+
this.viewManager = AppUtils.resolve('viewManager');
|
|
437
|
+
this.viewBuilder = AppUtils.resolve('viewBuilder');
|
|
438
|
+
this.focusManager = AppUtils.resolve('focusManager');
|
|
439
|
+
this.instancePool = AppUtils.resolve('instancePool');
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** The app defers notification subscriptions until its services are ready. */
|
|
443
|
+
protected initializeViewNotifications(): void {
|
|
412
444
|
if ((this as INotificationClient).notificationHandlers) {
|
|
413
445
|
toggleNotificationSubscription(this as INotificationClient, true);
|
|
414
446
|
}
|
|
@@ -811,6 +843,10 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
811
843
|
this.invalidateParentLayout();
|
|
812
844
|
this.notifyResize();
|
|
813
845
|
}
|
|
846
|
+
|
|
847
|
+
if (this.pendingViewModelFocus !== '') {
|
|
848
|
+
this.applyPendingViewModelFocus();
|
|
849
|
+
}
|
|
814
850
|
}
|
|
815
851
|
}
|
|
816
852
|
|
|
@@ -3352,9 +3388,52 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3352
3388
|
return;
|
|
3353
3389
|
}
|
|
3354
3390
|
this.lastReportedViewModelFocusId = focusedId;
|
|
3391
|
+
// Focus moved for another reason, so a request still waiting for its target is out of date.
|
|
3392
|
+
this.pendingViewModelFocus = '';
|
|
3355
3393
|
vm.focused(focusedId);
|
|
3356
3394
|
}
|
|
3357
3395
|
|
|
3396
|
+
private isViewModelFocusTargetReady(target: string): boolean {
|
|
3397
|
+
const child = this.getViewById(target) as IHosannaView<ViewState> | undefined;
|
|
3398
|
+
return child !== undefined && child.canReceiveFocus === true && child.visible === true;
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3401
|
+
/**
|
|
3402
|
+
* The model asked for a target before this view had rendered it, as when it
|
|
3403
|
+
* reveals a control and asks for focus on it in the same change. Called after
|
|
3404
|
+
* each render; applies the request once the target can take focus.
|
|
3405
|
+
*/
|
|
3406
|
+
private applyPendingViewModelFocus(): void {
|
|
3407
|
+
const target = this.pendingViewModelFocus;
|
|
3408
|
+
if (!this.viewModel || !this.isViewModelFocusTargetReady(target)) {
|
|
3409
|
+
return;
|
|
3410
|
+
}
|
|
3411
|
+
this.pendingViewModelFocus = '';
|
|
3412
|
+
if (this.isFocusOutsideThisView()) {
|
|
3413
|
+
// Focus left for another view while the request waited. Taking it back would steal it.
|
|
3414
|
+
return;
|
|
3415
|
+
}
|
|
3416
|
+
this.requestViewModelFocus(target);
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
/**
|
|
3420
|
+
* True when another view, outside this one, holds focus. This view is only
|
|
3421
|
+
* told about focus changes beneath it, so a move to a sibling is found here.
|
|
3422
|
+
*/
|
|
3423
|
+
private isFocusOutsideThisView(): boolean {
|
|
3424
|
+
let view = this.focusManager.focusedView as IHosannaView<ViewState> | undefined;
|
|
3425
|
+
if (!view) {
|
|
3426
|
+
return false;
|
|
3427
|
+
}
|
|
3428
|
+
while (view) {
|
|
3429
|
+
if (view._hid === this._hid) {
|
|
3430
|
+
return false;
|
|
3431
|
+
}
|
|
3432
|
+
view = view.parent as IHosannaView<ViewState> | undefined;
|
|
3433
|
+
}
|
|
3434
|
+
return true;
|
|
3435
|
+
}
|
|
3436
|
+
|
|
3358
3437
|
private getFocusedViewId(): string {
|
|
3359
3438
|
const focusedView = this.focusManager.focusedView as IHosannaView<ViewState> | undefined;
|
|
3360
3439
|
return focusedView?.id ?? '';
|
|
@@ -3376,8 +3455,14 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3376
3455
|
if (!current) {
|
|
3377
3456
|
return;
|
|
3378
3457
|
}
|
|
3379
|
-
if (field === 'focus'
|
|
3380
|
-
this.
|
|
3458
|
+
if (field === 'focus') {
|
|
3459
|
+
// A target that this view has not rendered yet is asked for again once it has.
|
|
3460
|
+
// An empty target means none, which also withdraws a request still waiting.
|
|
3461
|
+
const target = current.focus;
|
|
3462
|
+
this.pendingViewModelFocus = target === '' || this.isViewModelFocusTargetReady(target) ? '' : target;
|
|
3463
|
+
if (target !== '') {
|
|
3464
|
+
this.requestViewModelFocus(target);
|
|
3465
|
+
}
|
|
3381
3466
|
}
|
|
3382
3467
|
if (this.onViewModelChanged(field)) {
|
|
3383
3468
|
this.makeDirty('viewModel');
|
|
@@ -3402,6 +3487,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3402
3487
|
this.hasStartedViewModel = false;
|
|
3403
3488
|
this.boundViewModelHid = '';
|
|
3404
3489
|
this.lastReportedViewModelFocusId = '';
|
|
3490
|
+
this.pendingViewModelFocus = '';
|
|
3405
3491
|
this.bindViewModel();
|
|
3406
3492
|
}
|
|
3407
3493
|
|
|
@@ -3414,6 +3500,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3414
3500
|
vm.removeObservers(this);
|
|
3415
3501
|
this.boundViewModelHid = '';
|
|
3416
3502
|
this.lastReportedViewModelFocusId = '';
|
|
3503
|
+
this.pendingViewModelFocus = '';
|
|
3417
3504
|
if (!this.disposesViewModelOnUnmount) {
|
|
3418
3505
|
if (this.hasStartedViewModel) {
|
|
3419
3506
|
vm.suspend();
|
|
@@ -3442,6 +3529,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3442
3529
|
this.hasStartedViewModel = false;
|
|
3443
3530
|
this.boundViewModelHid = '';
|
|
3444
3531
|
this.lastReportedViewModelFocusId = '';
|
|
3532
|
+
this.pendingViewModelFocus = '';
|
|
3445
3533
|
}
|
|
3446
3534
|
|
|
3447
3535
|
/** Assignment to an `@observable` field: observe the new object, then store it. */
|