@xh/hoist 74.0.0-SNAPSHOT.1748339737885 → 74.0.0-SNAPSHOT.1748449301934

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,13 @@
2
2
 
3
3
  ## 74.0.0-SNAPSHOT - unreleased
4
4
 
5
+ ### 🎁 New Features
6
+ + Add `ViewManagerModel.preserveUnsavedChanges` flag to opt-out of that behaviour.
7
+
8
+ ### 🐞 Bug Fixes
9
+ + Improves `ViewManagerModel.settleTime` by comparing to when the view is pushed to components
10
+ rather than when view is loaded from the server.
11
+
5
12
  ## v73.0.1 - 2025-05-19
6
13
 
7
14
  ### 🐞 Bug Fixes
@@ -1,10 +1,12 @@
1
+ import { Persistable } from '@xh/hoist/core';
1
2
  import { PersistenceProvider, PersistenceProviderConfig } from '../PersistenceProvider';
2
3
  import type { ViewManagerModel } from '@xh/hoist/cmp/viewmanager/ViewManagerModel';
3
4
  export declare class ViewManagerProvider<S> extends PersistenceProvider<S> {
4
5
  readonly viewManagerModel: ViewManagerModel;
5
6
  constructor(cfg: PersistenceProviderConfig<S>);
6
7
  pushStateToTarget(): void;
7
- readRaw(): Partial<import("../..").PlainObject>;
8
+ bindToTarget(target: Persistable<S>): void;
9
+ readRaw(): Partial<import("@xh/hoist/core").PlainObject>;
8
10
  writeRaw(data: Record<typeof this.path, S>): void;
9
11
  destroy(): void;
10
12
  }
@@ -552,7 +552,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
552
552
  }
553
553
 
554
554
  this.addReaction(
555
- this.pendingValueReaction(),
555
+ this.preserveUnsavedChanges ? this.pendingValueReaction() : null,
556
556
  this.autoSaveReaction(),
557
557
  ...this.stateReactions(initialState)
558
558
  );
@@ -561,10 +561,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
561
561
  private pendingValueReaction(): ReactionSpec {
562
562
  return {
563
563
  track: () => this.pendingValue,
564
- run: v => {
565
- if (!this.preserveUnsavedChanges) return;
566
- XH.sessionStorageService.set(this.pendingValueStorageKey, v);
567
- }
564
+ run: v => XH.sessionStorageService.set(this.pendingValueStorageKey, v)
568
565
  };
569
566
  }
570
567
 
@@ -5,6 +5,7 @@
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
7
 
8
+ import {Persistable} from '@xh/hoist/core';
8
9
  import {throwIf} from '@xh/hoist/utils/js';
9
10
  import {pull} from 'lodash';
10
11
  import {PersistenceProvider, PersistenceProviderConfig} from '../PersistenceProvider';
@@ -19,7 +20,6 @@ export class ViewManagerProvider<S> extends PersistenceProvider<S> {
19
20
  throwIf(!viewManagerModel, `ViewManagerProvider requires a 'viewManagerModel'.`);
20
21
  this.viewManagerModel = viewManagerModel;
21
22
  viewManagerModel.providers.push(this);
22
- viewManagerModel.noteStatePushed();
23
23
  }
24
24
 
25
25
  pushStateToTarget() {
@@ -31,6 +31,11 @@ export class ViewManagerProvider<S> extends PersistenceProvider<S> {
31
31
  //----------------
32
32
  // Implementation
33
33
  //----------------
34
+ override bindToTarget(target: Persistable<S>) {
35
+ super.bindToTarget(target);
36
+ this.viewManagerModel.noteStatePushed();
37
+ }
38
+
34
39
  override readRaw() {
35
40
  return this.viewManagerModel.getValue();
36
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "74.0.0-SNAPSHOT.1748339737885",
3
+ "version": "74.0.0-SNAPSHOT.1748449301934",
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",