@xh/hoist 87.0.0-SNAPSHOT.1786360695388 → 87.0.0-SNAPSHOT.1786374740407

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
@@ -94,6 +94,7 @@
94
94
  `FetchService` can also share interned values across successive fetches of the same logical
95
95
  dataset, which the app identifies with a required key, per a configurable `retainMode`. Skip
96
96
  known high-cardinality fields (e.g. UUID columns) via `excludeFields`.
97
+ * `Store.loadData()` and `Cube.loadDataAsync` calls have been optimized to skip all downstream work.
97
98
 
98
99
  * Added an `icon` prop to `Badge`, rendered before the badge's content. Spacing between the icon and
99
100
  content is controlled by the new `--xh-badge-gap` CSS variable.
package/data/Store.ts CHANGED
@@ -527,9 +527,15 @@ export class Store
527
527
  ? castArray(rawSummaryData).map(it => this.createRecord(it, null, true))
528
528
  : null;
529
529
 
530
- const records = this.createRecords(rawData, null);
531
- this._committed = this._current = this._committed.withNewRecords(records);
532
- this.rebuildFiltered();
530
+ const {_committed, _current} = this,
531
+ records = this.createRecords(rawData, null),
532
+ updated = _committed.withNewRecords(records);
533
+
534
+ // Skip downstream work on no-change reloads, unless local mods are being discarded.
535
+ if (updated !== _committed || updated !== _current) {
536
+ this._committed = this._current = updated;
537
+ this.rebuildFiltered();
538
+ }
533
539
 
534
540
  this.lastLoaded = this.lastUpdated = Date.now();
535
541
  }
@@ -571,8 +577,12 @@ export class Store
571
577
 
572
578
  runInAction(() => {
573
579
  this.summaryRecords = null;
574
- this._committed = this._current = this._committed.withNewRecords(recordMap);
575
- this.rebuildFiltered();
580
+ const {_committed, _current} = this,
581
+ updated = _committed.withNewRecords(recordMap);
582
+ if (updated !== _committed || updated !== _current) {
583
+ this._committed = this._current = updated;
584
+ this.rebuildFiltered();
585
+ }
576
586
  this.lastLoaded = this.lastUpdated = Date.now();
577
587
  });
578
588
  }
package/data/cube/Cube.ts CHANGED
@@ -305,13 +305,20 @@ export class Cube extends HoistBase {
305
305
  rawData: PlainObject[] | AnyIterable<PlainObject>,
306
306
  info: PlainObject = {}
307
307
  ): Promise<void> {
308
+ const {store} = this,
309
+ prevRecords = store._filtered;
308
310
  if (isArray(rawData)) {
309
- this.store.loadData(rawData);
311
+ store.loadData(rawData);
310
312
  } else {
311
- await this.store.loadDataAsync(rawData);
313
+ await store.loadDataAsync(rawData);
312
314
  }
313
315
  this.setInfo(info);
314
- await forEachAsync(this._connectedViews, v => v.noteCubeLoaded());
316
+
317
+ // No-change loads need only an info/timestamp sync on views - skip row regeneration.
318
+ const unchanged = store._filtered === prevRecords;
319
+ await forEachAsync(this._connectedViews, v =>
320
+ unchanged ? v.noteCubeUpdated(null) : v.noteCubeLoaded()
321
+ );
315
322
  }
316
323
 
317
324
  /**
@@ -158,22 +158,22 @@ export class RecordSet {
158
158
  }
159
159
 
160
160
  withNewRecords(recordMap: StoreRecordMap): RecordSet {
161
- // Reuse existing StoreRecord object instances where possible. See Store.loadData().
161
+ // Reuse existing StoreRecord object instances where possible.
162
+ // If reload changed nothing - preserve instance identity outright,
162
163
  // Be sure to finalize any new records that are accepted.
163
- if (this.empty) {
164
- recordMap.forEach(r => r.finalize());
165
- } else {
166
- recordMap.forEach((newRec, id) => {
167
- const currRec = this.getById(id);
168
- if (currRec && this.areRecordsEqual(currRec, newRec)) {
169
- recordMap.set(id, currRec);
170
- } else {
171
- newRec.finalize();
172
- }
173
- });
174
- }
175
-
176
- return new RecordSet(this.store, recordMap);
164
+ let reused = 0;
165
+ recordMap.forEach((newRec, id) => {
166
+ const currRec = this.getById(id);
167
+ if (currRec && this.areRecordsEqual(currRec, newRec)) {
168
+ recordMap.set(id, currRec);
169
+ reused++;
170
+ } else {
171
+ newRec.finalize();
172
+ }
173
+ });
174
+ return reused === recordMap.size && reused === this.count
175
+ ? this
176
+ : new RecordSet(this.store, recordMap);
177
177
  }
178
178
 
179
179
  withTransaction(t: {
@@ -125,7 +125,8 @@ export class StoreValidator extends HoistBase {
125
125
  // Implementation
126
126
  //---------------------------------------
127
127
  private get uncommittedRecords() {
128
- return this.store.allRecords.filter(it => !it.isCommitted);
128
+ const {store} = this;
129
+ return store.isDirty ? store.allRecords.filter(it => !it.isCommitted) : [];
129
130
  }
130
131
 
131
132
  private async syncValidatorsAsync() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "87.0.0-SNAPSHOT.1786360695388",
3
+ "version": "87.0.0-SNAPSHOT.1786374740407",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": {
6
6
  "type": "git",