@xh/hoist 76.0.0-SNAPSHOT.1755706915375 → 76.0.0-SNAPSHOT.1755807786142

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## 76.0.0-SNAPSHOT - unreleased
4
4
 
5
+ ### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW - requires hoist-core v31.2)
6
+
5
7
  ### 🎁 New Features
6
8
 
7
9
  * Added new `extraConfirmText`, `extraConfirmLabel` properties to `MessageOptions`. Use this option
@@ -15,6 +17,9 @@
15
17
  * Handled an edge-case `ViewManager` bug where `enableDefault` changed to `false` after some user
16
18
  state had already been persisted w/users pointed at in-code default view. The manager now calls
17
19
  its configured `initialViewSpec` function as expected in this case.
20
+
21
+ * `XH.restoreDefaultsAsync` will now clear basic view state. Views themselves will be preserved.
22
+ Requires hoist-core v31.2
18
23
 
19
24
  ### ⚙️ Technical
20
25
 
@@ -51,12 +51,16 @@ export declare class HoistAppModel extends HoistModel {
51
51
  /**
52
52
  * Resets user preferences and any persistent local application state.
53
53
  *
54
- * The default implementation for this method will clear *all* preferences and local storage.
54
+ * The default implementation for this method will clear all preferences, local + session
55
+ * storage, and transient {@link ViewManager} state such as last-selected and pinned views.
56
+ * (Views themselves are preserved.)
55
57
  *
56
- * Applications may wish to override this method to do a more targeted clearing of state.
57
- * This is important for complex applications with smaller sub-applications, and/or device
58
+ * Applications may wish to override this method to perform a more targeted clearing of state.
59
+ * This is important for complex applications with smaller sub-applications and/or device
58
60
  * specific applications. These applications will typically want to perform a custom clearing
59
- * that is more targeted, and includes any additional app-specific state.
61
+ * that is more targeted and/or clears additional app-specific state.
62
+ *
63
+ * Not typically called directly by apps - call {@link XHApi.restoreDefaultsAsync} instead.
60
64
  */
61
65
  restoreDefaultsAsync(): Promise<void>;
62
66
  }
@@ -11,7 +11,7 @@ import { ToastModel } from '../appcontainer/ToastModel';
11
11
  import '../styles/XH.scss';
12
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
- export declare const MIN_HOIST_CORE_VERSION = "30.1";
14
+ export declare const MIN_HOIST_CORE_VERSION = "31.2";
15
15
  /**
16
16
  * Top-level Singleton model for Hoist. This is the main entry point for the API.
17
17
  *
@@ -396,7 +396,8 @@ export declare class XHApi {
396
396
  /** All Stores registered with this application. */
397
397
  getStores(): Store[];
398
398
  /**
399
- * Reset user preferences and any persistent local application state, then reload the app.
399
+ * Reset user state and then reload the app.
400
+ * @see HoistAppModel.restoreDefaultsAsync()
400
401
  */
401
402
  restoreDefaultsAsync(): Promise<void>;
402
403
  /**
@@ -56,11 +56,6 @@ export declare class PrefService extends HoistService {
56
56
  * before making another call that relies on its updated value being read on the server.
57
57
  */
58
58
  pushAsync(key: string, value: any): Promise<void>;
59
- /**
60
- * Reset *all* preferences, reverting their effective values back to defaults.
61
- * @returns a Promise that resolves when preferences have been cleared and defaults reloaded.
62
- */
63
- clearAllAsync(): Promise<void>;
64
59
  /**
65
60
  * Push any pending buffered updates to persist newly set values to server.
66
61
  * Called automatically by this app on page unload to avoid dropping changes when e.g. a user
@@ -88,16 +88,23 @@ export class HoistAppModel extends HoistModel {
88
88
  /**
89
89
  * Resets user preferences and any persistent local application state.
90
90
  *
91
- * The default implementation for this method will clear *all* preferences and local storage.
91
+ * The default implementation for this method will clear all preferences, local + session
92
+ * storage, and transient {@link ViewManager} state such as last-selected and pinned views.
93
+ * (Views themselves are preserved.)
92
94
  *
93
- * Applications may wish to override this method to do a more targeted clearing of state.
94
- * This is important for complex applications with smaller sub-applications, and/or device
95
+ * Applications may wish to override this method to perform a more targeted clearing of state.
96
+ * This is important for complex applications with smaller sub-applications and/or device
95
97
  * specific applications. These applications will typically want to perform a custom clearing
96
- * that is more targeted, and includes any additional app-specific state.
98
+ * that is more targeted and/or clears additional app-specific state.
99
+ *
100
+ * Not typically called directly by apps - call {@link XHApi.restoreDefaultsAsync} instead.
97
101
  */
98
102
  async restoreDefaultsAsync() {
99
103
  const XH = window['XH'];
100
- await XH.prefService.clearAllAsync();
104
+ await XH.fetchJson({
105
+ url: 'xh/clearUserState',
106
+ params: {clientUsername: XH.getUsername()}
107
+ });
101
108
  XH.localStorageService.clear();
102
109
  XH.sessionStorageService.clear();
103
110
  }
package/core/XH.ts CHANGED
@@ -67,7 +67,7 @@ import {instanceManager} from './impl/InstanceManager';
67
67
  import {HoistModel, ModelSelector, RefreshContextModel} from './model';
68
68
  import ShortUniqueId from 'short-unique-id';
69
69
 
70
- export const MIN_HOIST_CORE_VERSION = '30.1';
70
+ export const MIN_HOIST_CORE_VERSION = '31.2';
71
71
 
72
72
  declare const xhAppCode: string;
73
73
  declare const xhAppName: string;
@@ -772,11 +772,20 @@ export class XHApi {
772
772
  }
773
773
 
774
774
  /**
775
- * Reset user preferences and any persistent local application state, then reload the app.
775
+ * Reset user state and then reload the app.
776
+ * @see HoistAppModel.restoreDefaultsAsync()
776
777
  */
777
778
  async restoreDefaultsAsync() {
778
- await this.appModel.restoreDefaultsAsync();
779
- this.reloadApp();
779
+ try {
780
+ await this.appModel.restoreDefaultsAsync();
781
+ XH.track({category: 'App', message: 'Restored app defaults'});
782
+ this.reloadApp();
783
+ } catch (e) {
784
+ XH.handleException(e, {
785
+ message: 'Failed to restore app defaults',
786
+ requireReload: true
787
+ });
788
+ }
780
789
  }
781
790
 
782
791
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "76.0.0-SNAPSHOT.1755706915375",
3
+ "version": "76.0.0-SNAPSHOT.1755807786142",
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",
@@ -110,18 +110,6 @@ export class PrefService extends HoistService {
110
110
  return this.pushPendingAsync();
111
111
  }
112
112
 
113
- /**
114
- * Reset *all* preferences, reverting their effective values back to defaults.
115
- * @returns a Promise that resolves when preferences have been cleared and defaults reloaded.
116
- */
117
- async clearAllAsync() {
118
- await XH.fetchJson({
119
- url: 'xh/clearPrefs',
120
- params: {clientUsername: XH.getUsername()}
121
- });
122
- return this.loadPrefsAsync();
123
- }
124
-
125
113
  /**
126
114
  * Push any pending buffered updates to persist newly set values to server.
127
115
  * Called automatically by this app on page unload to avoid dropping changes when e.g. a user