@unicitylabs/sphere-sdk 0.14.11-dev.5 → 0.14.11-dev.6

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/dist/index.js CHANGED
@@ -13835,15 +13835,25 @@ function parseAmount(raw) {
13835
13835
  function supportsDeterministicMint(engine) {
13836
13836
  return engine.deterministicMint === true;
13837
13837
  }
13838
- function makeSingleFlightRefresh(refresh) {
13838
+ function makeCoalescedRefresh(refresh) {
13839
13839
  let inFlight = false;
13840
- return () => {
13841
- if (inFlight) return;
13840
+ let queued = false;
13841
+ const run = () => {
13842
13842
  inFlight = true;
13843
13843
  void refresh().catch(() => void 0).finally(() => {
13844
13844
  inFlight = false;
13845
+ if (!queued) return;
13846
+ queued = false;
13847
+ run();
13845
13848
  });
13846
13849
  };
13850
+ return () => {
13851
+ if (inFlight) {
13852
+ queued = true;
13853
+ return;
13854
+ }
13855
+ run();
13856
+ };
13847
13857
  }
13848
13858
  function composeFacadeParts(deps, hooks) {
13849
13859
  const ownPubkeyBytes = hexToBytes4(deps.ownPubkey);
@@ -13966,10 +13976,8 @@ function buildReceive(deps, hooks, historyStore, heldStates, view) {
13966
13976
  registry: deps.registry,
13967
13977
  recordReceived: (record) => recordReceived(historyStore, record),
13968
13978
  emit: (event, transfer) => deps.emit(event, transfer),
13969
- // Single-flight: view.delta() enqueues on a strict-FIFO SerialChain, so
13970
- // firing per throttle tick regardless of the last one builds a queue that
13971
- // drains in a burst at the END — a slower version of the bug being fixed.
13972
- refreshView: makeSingleFlightRefresh(() => view.delta()),
13979
+ // Coalesced — see makeCoalescedRefresh.
13980
+ refreshView: makeCoalescedRefresh(() => view.delta()),
13973
13981
  attention: (transferId, code, detail) => {
13974
13982
  deps.emit(
13975
13983
  "transfer:attention",
@@ -14021,6 +14029,7 @@ var PaymentsFacade = class {
14021
14029
  isActiveOp: (id) => this.activeMoneyOps.has(id)
14022
14030
  });
14023
14031
  this.view = parts.view;
14032
+ this.wakeRefresh = makeCoalescedRefresh(() => this.view.delta());
14024
14033
  this.ledger = parts.ledger;
14025
14034
  this.queue = parts.queue;
14026
14035
  this.machine = parts.machine;
@@ -14050,6 +14059,7 @@ var PaymentsFacade = class {
14050
14059
  now: () => this.nowMs()
14051
14060
  });
14052
14061
  }
14062
+ wakeRefresh;
14053
14063
  prewarmed = new PrewarmCache();
14054
14064
  view;
14055
14065
  ledger;
@@ -14088,9 +14098,7 @@ var PaymentsFacade = class {
14088
14098
  this.deps.session.subscribeStream("mailbox", () => {
14089
14099
  this.trackTail(this.receiveLoop.drainOnce());
14090
14100
  }),
14091
- this.deps.session.subscribeStream("inventory", () => {
14092
- this.trackTail(this.view.delta());
14093
- }),
14101
+ this.deps.session.subscribeStream("inventory", this.wakeRefresh),
14094
14102
  this.deps.session.subscribeStream("payment_requests", () => {
14095
14103
  this.trackTail(this.requests.drainIncoming());
14096
14104
  })