@xh/hoist 73.0.0-SNAPSHOT.1741790055811 → 73.0.0-SNAPSHOT.1741793208717

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/CHANGELOG.md CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  * Modify `TabContainerModel` to make more methods `protected`, improving extensibility for advanced
8
8
  use-cases.
9
+ * Enhance `XH.reloadApp` with new argument to clear query parameters before loading.
9
10
  * Enhance exception handling in `FetchService` to capture messages returned as raw strings, or without
10
11
  explicit names.
11
12
 
@@ -9,7 +9,7 @@ import { AppContainerModel } from '../appcontainer/AppContainerModel';
9
9
  import { BannerModel } from '../appcontainer/BannerModel';
10
10
  import { ToastModel } from '../appcontainer/ToastModel';
11
11
  import '../styles/XH.scss';
12
- import { AppSpec, AppState, AppSuspendData, BannerSpec, ExceptionHandler, ExceptionHandlerOptions, HoistAppModel, HoistException, HoistService, HoistServiceClass, HoistUser, MessageSpec, PageState, PlainObject, SizingMode, TaskObserver, Theme, ToastSpec, TrackOptions } from './';
12
+ import { AppSpec, AppState, AppSuspendData, BannerSpec, ExceptionHandler, ExceptionHandlerOptions, HoistAppModel, HoistException, HoistService, HoistServiceClass, HoistUser, MessageSpec, PageState, PlainObject, ReloadAppOptions, SizingMode, TaskObserver, Theme, ToastSpec, TrackOptions } from './';
13
13
  import { HoistModel, ModelSelector, RefreshContextModel } from './model';
14
14
  export declare const MIN_HOIST_CORE_VERSION = "28.0";
15
15
  /**
@@ -193,13 +193,13 @@ export declare class XHApi {
193
193
  /**
194
194
  * Trigger a full reload of the current application.
195
195
  *
196
- * @param path - relative path to reload (e.g. 'mobile/'). Defaults to the
197
- * existing location pathname.
196
+ * @param opts - options to govern reload. To support legacy usages, a provided
197
+ * string will be treated as `ReloadAppOptions.path`.
198
198
  *
199
199
  * This method will reload the entire application document in the browser - to trigger a
200
200
  * refresh of the loadable content within the app, use {@link refreshAppAsync} instead.
201
201
  */
202
- reloadApp(path?: string): void;
202
+ reloadApp(opts?: ReloadAppOptions | string): void;
203
203
  /**
204
204
  * Refresh the current application.
205
205
  *
@@ -19,6 +19,15 @@ export interface HoistUser {
19
19
  hasRole(s: string): boolean;
20
20
  hasGate(s: string): boolean;
21
21
  }
22
+ /**
23
+ * Options governing XH.reloadApp().
24
+ */
25
+ export interface ReloadAppOptions {
26
+ /** Relative path to reload (e.g. 'mobile/'). Defaults to the existing location pathname. */
27
+ path?: string;
28
+ /** Should the query parameters be removed from the url before reload. Default false. */
29
+ removeQueryParams?: boolean;
30
+ }
22
31
  /**
23
32
  * Options for showing a "toast" notification that appears and then automatically dismisses.
24
33
  */
package/core/XH.ts CHANGED
@@ -54,6 +54,7 @@ import {
54
54
  MessageSpec,
55
55
  PageState,
56
56
  PlainObject,
57
+ ReloadAppOptions,
57
58
  SizingMode,
58
59
  TaskObserver,
59
60
  Theme,
@@ -392,18 +393,25 @@ export class XHApi {
392
393
  /**
393
394
  * Trigger a full reload of the current application.
394
395
  *
395
- * @param path - relative path to reload (e.g. 'mobile/'). Defaults to the
396
- * existing location pathname.
396
+ * @param opts - options to govern reload. To support legacy usages, a provided
397
+ * string will be treated as `ReloadAppOptions.path`.
397
398
  *
398
399
  * This method will reload the entire application document in the browser - to trigger a
399
400
  * refresh of the loadable content within the app, use {@link refreshAppAsync} instead.
400
401
  */
401
402
  @action
402
- reloadApp(path?: string) {
403
+ reloadApp(opts?: ReloadAppOptions | string) {
403
404
  never().linkTo(this.appLoadModel);
405
+
406
+ opts = isString(opts) ? {path: opts} : (opts ?? {});
407
+
404
408
  const {location} = window,
405
- href = path ? `${location.origin}/${path.replace(/^\/+/, '')}` : location.href,
409
+ href = opts.path
410
+ ? `${location.origin}/${opts.path.replace(/^\/+/, '')}`
411
+ : location.href,
406
412
  url = new URL(href);
413
+
414
+ if (opts.removeQueryParams) url.search = '';
407
415
  // Add a unique query param to force a full reload without using the browser cache.
408
416
  url.searchParams.set('xhCacheBuster', Date.now().toString());
409
417
  document.location.assign(url);
@@ -28,6 +28,17 @@ export interface HoistUser {
28
28
  hasGate(s: string): boolean;
29
29
  }
30
30
 
31
+ /**
32
+ * Options governing XH.reloadApp().
33
+ */
34
+ export interface ReloadAppOptions {
35
+ /** Relative path to reload (e.g. 'mobile/'). Defaults to the existing location pathname. */
36
+ path?: string;
37
+
38
+ /** Should the query parameters be removed from the url before reload. Default false. */
39
+ removeQueryParams?: boolean;
40
+ }
41
+
31
42
  /**
32
43
  * Options for showing a "toast" notification that appears and then automatically dismisses.
33
44
  */
@@ -79,7 +79,7 @@ export const dismissButton = hoistCmp.factory<ExceptionDialogModel>(({model}) =>
79
79
  icon: Icon.refresh(),
80
80
  text: 'Reload App',
81
81
  autoFocus: true,
82
- onClick: () => XH.reloadApp()
82
+ onClick: () => XH.reloadApp({removeQueryParams: true})
83
83
  })
84
84
  : button({
85
85
  text: 'Close',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "73.0.0-SNAPSHOT.1741790055811",
3
+ "version": "73.0.0-SNAPSHOT.1741793208717",
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",