@xh/hoist 73.0.0-SNAPSHOT.1747155067044 → 73.0.0-SNAPSHOT.1747231011044

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 (27) hide show
  1. package/appcontainer/AppContainerModel.ts +4 -0
  2. package/build/types/appcontainer/AppContainerModel.d.ts +1 -0
  3. package/build/types/core/types/AppState.d.ts +2 -1
  4. package/build/types/{mobile/appcontainer → desktop/appcontainer/suspend}/SuspendPanel.d.ts +1 -1
  5. package/core/types/AppState.ts +2 -1
  6. package/desktop/appcontainer/AppContainer.ts +2 -15
  7. package/desktop/appcontainer/VersionBar.ts +1 -1
  8. package/desktop/appcontainer/{SuspendPanel.ts → suspend/SuspendPanel.ts} +39 -4
  9. package/desktop/cmp/button/AppMenuButton.ts +1 -1
  10. package/desktop/cmp/button/LaunchAdminButton.ts +1 -1
  11. package/mobile/appcontainer/AppContainer.ts +2 -15
  12. package/mobile/appcontainer/suspend/SuspendPanel.ts +94 -0
  13. package/package.json +1 -1
  14. package/security/BaseOAuthClient.ts +17 -8
  15. package/tsconfig.tsbuildinfo +1 -1
  16. package/mobile/appcontainer/SuspendPanel.ts +0 -56
  17. /package/build/types/desktop/appcontainer/{IdlePanel.d.ts → suspend/IdlePanel.d.ts} +0 -0
  18. /package/build/types/mobile/appcontainer/{IdlePanel.d.ts → suspend/IdlePanel.d.ts} +0 -0
  19. /package/build/types/{desktop/appcontainer → mobile/appcontainer/suspend}/SuspendPanel.d.ts +0 -0
  20. /package/desktop/appcontainer/{IdlePanel.scss → suspend/IdlePanel.scss} +0 -0
  21. /package/desktop/appcontainer/{IdlePanel.ts → suspend/IdlePanel.ts} +0 -0
  22. /package/desktop/appcontainer/{IdlePanelImage.png → suspend/IdlePanelImage.png} +0 -0
  23. /package/desktop/appcontainer/{SuspendPanel.scss → suspend/SuspendPanel.scss} +0 -0
  24. /package/mobile/appcontainer/{IdlePanel.scss → suspend/IdlePanel.scss} +0 -0
  25. /package/mobile/appcontainer/{IdlePanel.ts → suspend/IdlePanel.ts} +0 -0
  26. /package/mobile/appcontainer/{IdlePanelImage.png → suspend/IdlePanelImage.png} +0 -0
  27. /package/mobile/appcontainer/{SuspendPanel.scss → suspend/SuspendPanel.scss} +0 -0
@@ -343,6 +343,10 @@ export class AppContainerModel extends HoistModel {
343
343
  return !isEmpty(this.aboutDialogModel.getItems());
344
344
  }
345
345
 
346
+ openAdmin() {
347
+ XH.openWindow('/admin', XH.appCode + '_xhAdmin');
348
+ }
349
+
346
350
  //----------------------------
347
351
  // Implementation
348
352
  //-----------------------------
@@ -82,6 +82,7 @@ export declare class AppContainerModel extends HoistModel {
82
82
  */
83
83
  showUpdateBanner(version: string, build?: string): void;
84
84
  hasAboutDialog(): boolean;
85
+ openAdmin(): void;
85
86
  private setDocTitle;
86
87
  private startRouter;
87
88
  private startOptionsDialog;
@@ -14,6 +14,7 @@ export declare const AppState: Readonly<{
14
14
  }>;
15
15
  export type AppState = (typeof AppState)[keyof typeof AppState];
16
16
  export interface AppSuspendData {
17
- message?: string;
18
17
  reason: 'IDLE' | 'SERVER_FORCE' | 'APP_UPDATE' | 'AUTH_EXPIRED';
18
+ message?: string;
19
+ exception?: unknown;
19
20
  }
@@ -1,7 +1,7 @@
1
1
  import { AppContainerModel } from '@xh/hoist/appcontainer/AppContainerModel';
2
2
  import './SuspendPanel.scss';
3
3
  /**
4
- * Generic Panel to display when the app is suspended.
4
+ * Display when the app is suspended.
5
5
  * @internal
6
6
  */
7
7
  export declare const suspendPanel: import("@xh/hoist/core").ElementFactory<import("@xh/hoist/core").DefaultHoistProps<AppContainerModel>>;
@@ -27,6 +27,7 @@ export const AppState = Object.freeze({
27
27
  export type AppState = (typeof AppState)[keyof typeof AppState];
28
28
 
29
29
  export interface AppSuspendData {
30
+ reason: 'IDLE' | 'SERVER_FORCE' | 'APP_UPDATE' | 'AUTH_EXPIRED';
30
31
  message?: string;
31
- reason: 'IDLE'|'SERVER_FORCE'|'APP_UPDATE'|'AUTH_EXPIRED';
32
+ exception?: unknown;
32
33
  }
@@ -9,7 +9,7 @@ import {fragment, frame, vframe, viewport} from '@xh/hoist/cmp/layout';
9
9
  import {createElement, hoistCmp, refreshContextView, uses, XH} from '@xh/hoist/core';
10
10
  import {errorBoundary} from '@xh/hoist/cmp/error/ErrorBoundary';
11
11
  import {changelogDialog} from '@xh/hoist/desktop/appcontainer/ChangelogDialog';
12
- import {suspendPanel} from '@xh/hoist/desktop/appcontainer/SuspendPanel';
12
+ import {suspendPanel} from './suspend/SuspendPanel';
13
13
  import {dockContainerImpl} from '@xh/hoist/desktop/cmp/dock/impl/DockContainer';
14
14
  import {colChooserDialog as colChooser} from '@xh/hoist/desktop/cmp/grid/impl/colchooser/ColChooserDialog';
15
15
  import {ColChooserModel} from '@xh/hoist/desktop/cmp/grid/impl/colchooser/ColChooserModel';
@@ -34,7 +34,6 @@ import {aboutDialog} from './AboutDialog';
34
34
  import {banner} from './Banner';
35
35
  import {exceptionDialog} from './ExceptionDialog';
36
36
  import {feedbackDialog} from './FeedbackDialog';
37
- import {idlePanel} from './IdlePanel';
38
37
  import {impersonationBar} from './ImpersonationBar';
39
38
  import {lockoutPanel} from './LockoutPanel';
40
39
  import {loginPanel} from './LoginPanel';
@@ -172,19 +171,7 @@ const appLoadMask = hoistCmp.factory<AppContainerModel>(({model}) =>
172
171
  mask({bind: model.appLoadModel, spinner: true})
173
172
  );
174
173
 
175
- const suspendedView = hoistCmp.factory<AppContainerModel>({
176
- render({model}) {
177
- let ret;
178
- if (model.appStateModel.suspendData?.reason === 'IDLE') {
179
- const content = model.appSpec.idlePanel ?? idlePanel;
180
- ret = elementFromContent(content, {onReactivate: () => XH.reloadApp()});
181
- } else {
182
- ret = suspendPanel();
183
- }
184
-
185
- return viewport(ret, appLoadMask());
186
- }
187
- });
174
+ const suspendedView = hoistCmp.factory(() => viewport(suspendPanel(), appLoadMask()));
188
175
 
189
176
  const bannerList = hoistCmp.factory<AppContainerModel>({
190
177
  render({model}) {
@@ -55,7 +55,7 @@ export const versionBar = hoistCmp.factory({
55
55
  Icon.wrench({
56
56
  omit: isAdminApp || !XH.getUser().isHoistAdminReader,
57
57
  title: 'Open Admin Console',
58
- onClick: () => XH.openWindow('/admin', 'xhAdmin')
58
+ onClick: () => XH.appContainerModel.openAdmin()
59
59
  })
60
60
  ]
61
61
  });
@@ -10,26 +10,54 @@ import {viewport, div, p, filler} from '@xh/hoist/cmp/layout';
10
10
  import {panel} from '@xh/hoist/desktop/cmp/panel';
11
11
  import {button} from '@xh/hoist/desktop/cmp/button';
12
12
  import {Icon} from '@xh/hoist/icon';
13
+ import {idlePanel} from './IdlePanel';
13
14
 
14
15
  import './SuspendPanel.scss';
16
+ import {elementFromContent} from '@xh/hoist/utils/react';
15
17
 
16
18
  /**
17
- * Generic Panel to display when the app is suspended.
19
+ * Display when the app is suspended.
18
20
  * @internal
19
21
  */
20
22
  export const suspendPanel = hoistCmp.factory<AppContainerModel>({
21
23
  displayName: 'SuspendPanel',
22
24
 
23
25
  render({model}) {
24
- const message = model.appStateModel.suspendData?.message;
26
+ const {suspendData} = model.appStateModel;
27
+ if (!suspendData) return null;
28
+
29
+ let {reason, exception, message} = suspendData;
30
+
31
+ // 0) Special case for IDLE, including app override ability.
32
+ if (reason === 'IDLE') {
33
+ const content = model.appSpec.idlePanel ?? idlePanel;
34
+ return elementFromContent(content, {onReactivate: () => XH.reloadApp()});
35
+ }
36
+
37
+ // 1) All Others
38
+ let icon, title;
39
+ switch (reason) {
40
+ case 'APP_UPDATE':
41
+ icon = Icon.gift();
42
+ title = 'Application Update';
43
+ break;
44
+ case 'AUTH_EXPIRED':
45
+ icon = Icon.lock();
46
+ title = 'Authentication Expired';
47
+ break;
48
+ default:
49
+ icon = Icon.refresh();
50
+ title = 'Reload Required';
51
+ }
52
+
25
53
  return viewport({
26
54
  alignItems: 'center',
27
55
  justifyContent: 'center',
28
56
  flexDirection: 'column',
29
57
  className: 'xh-suspend-viewport',
30
58
  item: panel({
31
- title: `Reload Required`,
32
- icon: Icon.refresh(),
59
+ title,
60
+ icon,
33
61
  className: 'xh-suspend-panel',
34
62
  item: div({
35
63
  className: 'xh-suspend-panel__inner',
@@ -39,6 +67,13 @@ export const suspendPanel = hoistCmp.factory<AppContainerModel>({
39
67
  ]
40
68
  }),
41
69
  bbar: [
70
+ button({
71
+ text: 'More Details',
72
+ icon: Icon.detail(),
73
+ minimal: true,
74
+ omit: !exception,
75
+ onClick: () => XH.exceptionHandler.showExceptionDetails(exception)
76
+ }),
42
77
  filler(),
43
78
  button({
44
79
  text: 'Reload now',
@@ -143,7 +143,7 @@ function buildMenuItems(props: AppMenuButtonProps) {
143
143
  omit: hideAdminItem,
144
144
  text: 'Admin',
145
145
  icon: Icon.wrench(),
146
- actionFn: () => XH.openWindow('/admin', 'xhAdmin')
146
+ actionFn: () => XH.appContainerModel.openAdmin()
147
147
  },
148
148
  {
149
149
  omit: hideImpersonateItem,
@@ -25,7 +25,7 @@ export const [LaunchAdminButton, launchAdminButton] = hoistCmp.withFactory<Launc
25
25
  ref,
26
26
  icon: Icon.wrench(),
27
27
  title: 'Launch admin client...',
28
- onClick: () => XH.openWindow('/admin', 'xhAdmin'),
28
+ onClick: () => XH.appContainerModel.openAdmin(),
29
29
  ...props
30
30
  });
31
31
  }
@@ -24,13 +24,12 @@ import {aboutDialog} from './AboutDialog';
24
24
  import {banner} from './Banner';
25
25
  import {exceptionDialog} from './ExceptionDialog';
26
26
  import {feedbackDialog} from './FeedbackDialog';
27
- import {idlePanel} from './IdlePanel';
28
27
  import {impersonationBar} from './ImpersonationBar';
29
28
  import {lockoutPanel} from './LockoutPanel';
30
29
  import {loginPanel} from './LoginPanel';
31
30
  import {messageSource} from './MessageSource';
32
31
  import {optionsDialog} from './OptionsDialog';
33
- import {suspendPanel} from './SuspendPanel';
32
+ import {suspendPanel} from './suspend/SuspendPanel';
34
33
  import {toastSource} from './ToastSource';
35
34
  import {versionBar} from './VersionBar';
36
35
 
@@ -157,16 +156,4 @@ const bannerList = hoistCmp.factory<AppContainerModel>({
157
156
  }
158
157
  });
159
158
 
160
- const suspendedView = hoistCmp.factory<AppContainerModel>({
161
- render({model}) {
162
- let ret;
163
- if (model.appStateModel.suspendData?.reason === 'IDLE') {
164
- const content = model.appSpec.idlePanel ?? idlePanel;
165
- ret = elementFromContent(content, {onReactivate: () => XH.reloadApp()});
166
- } else {
167
- ret = suspendPanel();
168
- }
169
-
170
- return viewport(ret, appLoadMask());
171
- }
172
- });
159
+ const suspendedView = hoistCmp.factory(() => viewport(suspendPanel(), appLoadMask()));
@@ -0,0 +1,94 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2025 Extremely Heavy Industries Inc.
6
+ */
7
+
8
+ import {AppContainerModel} from '@xh/hoist/appcontainer/AppContainerModel';
9
+ import {XH, hoistCmp} from '@xh/hoist/core';
10
+ import {vframe, div, p} from '@xh/hoist/cmp/layout';
11
+ import {panel} from '@xh/hoist/mobile/cmp/panel';
12
+ import {Icon} from '@xh/hoist/icon';
13
+ import {button} from '@xh/hoist/mobile/cmp/button';
14
+
15
+ import './SuspendPanel.scss';
16
+ import {idlePanel} from './IdlePanel';
17
+ import {elementFromContent} from '@xh/hoist/utils/react';
18
+
19
+ /**
20
+ * Generic Panel to display when the app is suspended.
21
+ * @internal
22
+ */
23
+ export const suspendPanel = hoistCmp.factory<AppContainerModel>({
24
+ displayName: 'SuspendPanel',
25
+
26
+ render({model}) {
27
+ const {suspendData} = model.appStateModel;
28
+ if (!suspendData) return null;
29
+
30
+ let {reason, exception, message} = suspendData;
31
+
32
+ // 0) Special case for IDLE, including app override ability.
33
+ if (reason === 'IDLE') {
34
+ const content = model.appSpec.idlePanel ?? idlePanel;
35
+ return elementFromContent(content, {onReactivate: () => XH.reloadApp()});
36
+ }
37
+
38
+ // 1) All Others
39
+ let icon, title;
40
+ switch (reason) {
41
+ case 'APP_UPDATE':
42
+ icon = Icon.gift();
43
+ title = 'Application Update';
44
+ break;
45
+ case 'AUTH_EXPIRED':
46
+ icon = Icon.lock();
47
+ title = 'Authentication Expired';
48
+ break;
49
+ default:
50
+ icon = Icon.refresh();
51
+ title = 'Reload Required';
52
+ }
53
+
54
+ return panel({
55
+ className: 'xh-suspend-panel',
56
+ title,
57
+ icon,
58
+ items: [
59
+ vframe({
60
+ className: 'xh-suspend-panel__content',
61
+ items: [
62
+ div({
63
+ className: 'xh-suspend-panel__text-container',
64
+ items: [
65
+ p({item: message, omit: !message}),
66
+ p(`${XH.clientAppName} must be reloaded to continue.`)
67
+ ]
68
+ }),
69
+ div({
70
+ className: 'xh-suspend-panel__button-container',
71
+ items: [
72
+ button({
73
+ text: 'Reload Now',
74
+ icon: Icon.refresh(),
75
+ intent: 'primary',
76
+ flex: 1,
77
+ onClick: () => XH.reloadApp()
78
+ }),
79
+ button({
80
+ text: 'More Details',
81
+ icon: Icon.detail(),
82
+ minimal: true,
83
+ omit: !exception,
84
+ onClick: () =>
85
+ XH.exceptionHandler.showExceptionDetails(exception)
86
+ })
87
+ ]
88
+ })
89
+ ]
90
+ })
91
+ ]
92
+ });
93
+ }
94
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "73.0.0-SNAPSHOT.1747155067044",
3
+ "version": "73.0.0-SNAPSHOT.1747231011044",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",
@@ -5,7 +5,7 @@
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
7
  import {br, fragment} from '@xh/hoist/cmp/layout';
8
- import {HoistBase, managed, XH} from '@xh/hoist/core';
8
+ import {HoistBase, isHoistException, managed, XH} from '@xh/hoist/core';
9
9
  import {Icon} from '@xh/hoist/icon';
10
10
  import {action, makeObservable} from '@xh/hoist/mobx';
11
11
  import {never, wait} from '@xh/hoist/promise';
@@ -148,13 +148,22 @@ export abstract class BaseOAuthClient<
148
148
  * Main entry point for this object.
149
149
  */
150
150
  async initAsync(): Promise<void> {
151
- const tokens = await this.doInitAsync();
152
- this.logDebug('Successfully initialized with following tokens:');
153
- this.logTokensDebug(tokens);
154
- if (this.config.autoRefreshSecs > 0) {
155
- this.timer = Timer.create({
156
- runFn: async () => this.onTimerAsync(),
157
- interval: this.TIMER_INTERVAL
151
+ try {
152
+ const tokens = await this.doInitAsync();
153
+ this.logDebug('Successfully initialized with following tokens:');
154
+ this.logTokensDebug(tokens);
155
+ if (this.config.autoRefreshSecs > 0) {
156
+ this.timer = Timer.create({
157
+ runFn: async () => this.onTimerAsync(),
158
+ interval: this.TIMER_INTERVAL
159
+ });
160
+ }
161
+ } catch (e) {
162
+ if (isHoistException(e)) throw e;
163
+ throw XH.exception({
164
+ name: 'Auth Failed',
165
+ message: 'Authentication has failed.',
166
+ cause: e
158
167
  });
159
168
  }
160
169
  }