@xh/hoist 73.0.0-SNAPSHOT.1747153991877 → 73.0.0-SNAPSHOT.1747181587236

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 (29) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/admin/AppModel.ts +2 -1
  3. package/build/types/core/XH.d.ts +8 -0
  4. package/build/types/core/types/AppState.d.ts +2 -1
  5. package/build/types/{mobile/appcontainer → desktop/appcontainer/suspend}/SuspendPanel.d.ts +1 -1
  6. package/core/XH.ts +11 -0
  7. package/core/types/AppState.ts +2 -1
  8. package/desktop/appcontainer/AppContainer.ts +2 -15
  9. package/desktop/appcontainer/VersionBar.ts +1 -1
  10. package/desktop/appcontainer/{SuspendPanel.ts → suspend/SuspendPanel.ts} +39 -4
  11. package/desktop/cmp/button/AppMenuButton.ts +1 -1
  12. package/desktop/cmp/button/LaunchAdminButton.ts +1 -1
  13. package/mobile/appcontainer/AppContainer.ts +2 -15
  14. package/mobile/appcontainer/suspend/SuspendPanel.ts +94 -0
  15. package/package.json +1 -1
  16. package/security/BaseOAuthClient.ts +17 -8
  17. package/tsconfig.tsbuildinfo +1 -1
  18. package/mobile/appcontainer/SuspendPanel.ts +0 -56
  19. /package/build/types/desktop/appcontainer/{IdlePanel.d.ts → suspend/IdlePanel.d.ts} +0 -0
  20. /package/build/types/mobile/appcontainer/{IdlePanel.d.ts → suspend/IdlePanel.d.ts} +0 -0
  21. /package/build/types/{desktop/appcontainer → mobile/appcontainer/suspend}/SuspendPanel.d.ts +0 -0
  22. /package/desktop/appcontainer/{IdlePanel.scss → suspend/IdlePanel.scss} +0 -0
  23. /package/desktop/appcontainer/{IdlePanel.ts → suspend/IdlePanel.ts} +0 -0
  24. /package/desktop/appcontainer/{IdlePanelImage.png → suspend/IdlePanelImage.png} +0 -0
  25. /package/desktop/appcontainer/{SuspendPanel.scss → suspend/SuspendPanel.scss} +0 -0
  26. /package/mobile/appcontainer/{IdlePanel.scss → suspend/IdlePanel.scss} +0 -0
  27. /package/mobile/appcontainer/{IdlePanel.ts → suspend/IdlePanel.ts} +0 -0
  28. /package/mobile/appcontainer/{IdlePanelImage.png → suspend/IdlePanelImage.png} +0 -0
  29. /package/mobile/appcontainer/{SuspendPanel.scss → suspend/SuspendPanel.scss} +0 -0
package/CHANGELOG.md CHANGED
@@ -35,6 +35,8 @@
35
35
  allow the client to do a potentially interactive popup login during the session to re-establish
36
36
  the login. This is especially useful to allow recovery from expired or invalidated refresh
37
37
  tokens.
38
+ * New utility method `XH.openWindow()` for ensuring that new windows/tabs are opened without
39
+ an unintended `opener` relationship with the original window.
38
40
  * Improvements to Grid columns `HeaderFilter` component:
39
41
  * `GridFilterModel` `commitOnChage` now set to `false` by default
40
42
  * Addition of ability to append terms to active filter **only** when `commitOnChage:false`
package/admin/AppModel.ts CHANGED
@@ -155,7 +155,8 @@ export class AppModel extends HoistAppModel {
155
155
 
156
156
  /** Open the primary business-facing application, typically 'app'. */
157
157
  openPrimaryApp() {
158
- window.open(`/${this.getPrimaryAppCode()}`);
158
+ const appCode = this.getPrimaryAppCode();
159
+ XH.openWindow(`/${appCode}`, appCode);
159
160
  }
160
161
 
161
162
  getPrimaryAppCode() {
@@ -218,6 +218,14 @@ export declare class XHApi {
218
218
  * {@link reloadApp} instead.
219
219
  */
220
220
  refreshAppAsync(): Promise<void>;
221
+ /**
222
+ * Open a url in an external browser window/tab.
223
+ *
224
+ * Unlike a simple call to `open`, this method ensures the "opener" method on the
225
+ * new window is null. This ensures that the new page will not share sessionState with
226
+ * this page. See https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
227
+ */
228
+ openWindow(url: string, target?: string): void;
221
229
  /**
222
230
  * Flags for controlling experimental, hotfix, or otherwise provisional features.
223
231
  *
@@ -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>>;
package/core/XH.ts CHANGED
@@ -442,6 +442,17 @@ export class XHApi {
442
442
  return this.refreshContextModel.refreshAsync();
443
443
  }
444
444
 
445
+ /**
446
+ * Open a url in an external browser window/tab.
447
+ *
448
+ * Unlike a simple call to `open`, this method ensures the "opener" method on the
449
+ * new window is null. This ensures that the new page will not share sessionState with
450
+ * this page. See https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
451
+ */
452
+ openWindow(url: string, target?: string) {
453
+ window.open(url, target ?? '_blank', 'noopener=true');
454
+ }
455
+
445
456
  /**
446
457
  * Flags for controlling experimental, hotfix, or otherwise provisional features.
447
458
  *
@@ -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: () => window.open('/admin')
58
+ onClick: () => XH.openWindow('/admin', 'xhAdmin')
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: () => window.open('/admin')
146
+ actionFn: () => XH.openWindow('/admin', 'xhAdmin')
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: () => window.open('/admin'),
28
+ onClick: () => XH.openWindow('/admin', 'xhAdmin'),
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.1747153991877",
3
+ "version": "73.0.0-SNAPSHOT.1747181587236",
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
  }