@moonbase.sh/storefront 3.8.0 → 3.8.1

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/moonbase.js CHANGED
@@ -10834,7 +10834,7 @@ function xl() {
10834
10834
  }
10835
10835
  var ra = class pt {
10836
10836
  constructor(t, n, r) {
10837
- if (this.configuration = t, this.client = n, this.stateFactory = r, this.autoApplyItemOffers = /* @__PURE__ */ V(!1), this.closed = /* @__PURE__ */ V(!1), this.currentUser = /* @__PURE__ */ V(null), this.loadedUser = /* @__PURE__ */ V(!1), this.refreshOrderAbortController = new AbortController(), this.debouncedPushOrderContent = A_((m) => this.client.orders.pushContent(m, void 0, this.hasUtmOrReferrer ? this.utm.value : void 0), 500), typeof window > "u") {
10837
+ if (this.configuration = t, this.client = n, this.stateFactory = r, this.autoApplyItemOffers = /* @__PURE__ */ V(!1), this.closed = /* @__PURE__ */ V(!1), this.currentUser = /* @__PURE__ */ V(null), this.loadedUser = /* @__PURE__ */ V(!1), this.refreshOrderAbortController = new AbortController(), this.storefrontRefreshesStarted = 0, this.storefrontRefreshLanded = 0, this.debouncedPushOrderContent = A_((m) => this.client.orders.pushContent(m, void 0, this.hasUtmOrReferrer ? this.utm.value : void 0), 500), typeof window > "u") {
10838
10838
  this.currentOrder = /* @__PURE__ */ V({
10839
10839
  id: gs(),
10840
10840
  status: Qn.Open,
@@ -10913,7 +10913,7 @@ var ra = class pt {
10913
10913
  this.updateStorefront(), this.updateUser();
10914
10914
  }), window.addEventListener("moonbase-checkout-completed", (m) => {
10915
10915
  const p = m.detail.order;
10916
- p.id === this.currentOrder.value.id && this.resetOrder(), dd(p.id), this.updateUser();
10916
+ p.id === this.currentOrder.value.id && this.resetOrder(), dd(p.id), this.updateStorefront(), this.updateUser();
10917
10917
  });
10918
10918
  }
10919
10919
  get loadedStorefrontPromise() {
@@ -10969,17 +10969,18 @@ var ra = class pt {
10969
10969
  return this.currentUser.value;
10970
10970
  }
10971
10971
  async updateStorefront() {
10972
- let t;
10972
+ const t = ++this.storefrontRefreshesStarted;
10973
+ let n;
10973
10974
  try {
10974
- t = await this.client.storefront.get(this.hasUtmOrReferrer ? this.utm.value : void 0);
10975
- } catch (n) {
10976
- if (!(n instanceof sl))
10977
- throw n;
10975
+ n = await this.client.storefront.get(this.hasUtmOrReferrer ? this.utm.value : void 0);
10976
+ } catch (r) {
10977
+ if (!(r instanceof sl))
10978
+ throw r;
10978
10979
  return this.closeStore(), this.storefront.value;
10979
10980
  }
10980
- return t && (wo(pt.storefrontKey, JSON.stringify(t)), this.storefront.value = t, this.loadedStorefront.value = !0, this.currentOrder.value.currency = Ao(this.currentOrder.value, t), this.currentOrder.value.items = this.enrichLineItems(this.currentOrder.value.items), this.reconcileCartOffer() && this.currentOrder.value.items.length > 0 && this.pushOrderContent(), typeof window < "u" && window.dispatchEvent(new CustomEvent("moonbase-storefront-updated", {
10981
- detail: { storefront: t }
10982
- }))), t;
10981
+ return t < this.storefrontRefreshLanded ? this.storefront.value : (n && (this.storefrontRefreshLanded = t, wo(pt.storefrontKey, JSON.stringify(n)), this.storefront.value = n, this.loadedStorefront.value = !0, this.currentOrder.value.currency = Ao(this.currentOrder.value, n), this.currentOrder.value.items = this.enrichLineItems(this.currentOrder.value.items), this.reconcileCartOffer() && this.currentOrder.value.items.length > 0 && this.pushOrderContent(), typeof window < "u" && window.dispatchEvent(new CustomEvent("moonbase-storefront-updated", {
10982
+ detail: { storefront: n }
10983
+ }))), n);
10983
10984
  }
10984
10985
  /**
10985
10986
  * The store has closed for good, so nothing kept for it is any use: not the catalog a returning
@@ -19682,7 +19683,7 @@ const h4 = { class: "moonbase:about" }, p4 = {
19682
19683
  }, g4 = ["title"], b4 = /* @__PURE__ */ ae({
19683
19684
  __name: "About",
19684
19685
  setup(e) {
19685
- const t = ye(), n = typeof window < "u" && window.__moonbaseTestVersionOverride || "3.8.0", r = F(() => {
19686
+ const t = ye(), n = typeof window < "u" && window.__moonbaseTestVersionOverride || "3.8.1", r = F(() => {
19686
19687
  const i = n.match(/-(next)-/);
19687
19688
  if (i)
19688
19689
  return i[1];