@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.
@@ -13819,15 +13819,25 @@ function parseAmount(raw) {
13819
13819
  function supportsDeterministicMint(engine) {
13820
13820
  return engine.deterministicMint === true;
13821
13821
  }
13822
- function makeSingleFlightRefresh(refresh) {
13822
+ function makeCoalescedRefresh(refresh) {
13823
13823
  let inFlight = false;
13824
- return () => {
13825
- if (inFlight) return;
13824
+ let queued = false;
13825
+ const run = () => {
13826
13826
  inFlight = true;
13827
13827
  void refresh().catch(() => void 0).finally(() => {
13828
13828
  inFlight = false;
13829
+ if (!queued) return;
13830
+ queued = false;
13831
+ run();
13829
13832
  });
13830
13833
  };
13834
+ return () => {
13835
+ if (inFlight) {
13836
+ queued = true;
13837
+ return;
13838
+ }
13839
+ run();
13840
+ };
13831
13841
  }
13832
13842
  function composeFacadeParts(deps, hooks) {
13833
13843
  const ownPubkeyBytes = hexToBytes4(deps.ownPubkey);
@@ -13950,10 +13960,8 @@ function buildReceive(deps, hooks, historyStore, heldStates, view) {
13950
13960
  registry: deps.registry,
13951
13961
  recordReceived: (record) => recordReceived(historyStore, record),
13952
13962
  emit: (event, transfer) => deps.emit(event, transfer),
13953
- // Single-flight: view.delta() enqueues on a strict-FIFO SerialChain, so
13954
- // firing per throttle tick regardless of the last one builds a queue that
13955
- // drains in a burst at the END — a slower version of the bug being fixed.
13956
- refreshView: makeSingleFlightRefresh(() => view.delta()),
13963
+ // Coalesced — see makeCoalescedRefresh.
13964
+ refreshView: makeCoalescedRefresh(() => view.delta()),
13957
13965
  attention: (transferId, code, detail) => {
13958
13966
  deps.emit(
13959
13967
  "transfer:attention",
@@ -14005,6 +14013,7 @@ var PaymentsFacade = class {
14005
14013
  isActiveOp: (id) => this.activeMoneyOps.has(id)
14006
14014
  });
14007
14015
  this.view = parts.view;
14016
+ this.wakeRefresh = makeCoalescedRefresh(() => this.view.delta());
14008
14017
  this.ledger = parts.ledger;
14009
14018
  this.queue = parts.queue;
14010
14019
  this.machine = parts.machine;
@@ -14034,6 +14043,7 @@ var PaymentsFacade = class {
14034
14043
  now: () => this.nowMs()
14035
14044
  });
14036
14045
  }
14046
+ wakeRefresh;
14037
14047
  prewarmed = new PrewarmCache();
14038
14048
  view;
14039
14049
  ledger;
@@ -14072,9 +14082,7 @@ var PaymentsFacade = class {
14072
14082
  this.deps.session.subscribeStream("mailbox", () => {
14073
14083
  this.trackTail(this.receiveLoop.drainOnce());
14074
14084
  }),
14075
- this.deps.session.subscribeStream("inventory", () => {
14076
- this.trackTail(this.view.delta());
14077
- }),
14085
+ this.deps.session.subscribeStream("inventory", this.wakeRefresh),
14078
14086
  this.deps.session.subscribeStream("payment_requests", () => {
14079
14087
  this.trackTail(this.requests.drainIncoming());
14080
14088
  })