@moonbase.sh/storefront 2.5.1 → 2.5.2

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/README.md CHANGED
@@ -139,11 +139,11 @@ The widget can forward its commerce and auth events to common marketing/analytic
139
139
  ```ts
140
140
  Moonbase.setup('https://demo.moonbase.sh', {
141
141
  integrations: {
142
- metaPixel: { pixelId: '1234567890' },
143
- googleAnalytics: { measurementId: 'G-XXXXXXX' },
142
+ metaPixel: { pixelId: '1234567890' },
143
+ googleAnalytics: { measurementId: 'G-XXXXXXX' },
144
144
  googleTagManager: { containerId: 'GTM-XXXXXXX' },
145
- klaviyo: { companyId: 'ABC123' },
146
- tiktokPixel: { pixelId: 'C12345...' },
145
+ klaviyo: { companyId: 'ABC123' },
146
+ tiktokPixel: { pixelId: 'C12345...' },
147
147
  },
148
148
  })
149
149
  ```
package/dist/moonbase.js CHANGED
@@ -3192,17 +3192,17 @@ async function ua(e, t) {
3192
3192
  if (e.status === 403)
3193
3193
  throw new ap();
3194
3194
  let n;
3195
+ const r = await e.text();
3195
3196
  try {
3196
- const r = await e.json();
3197
- n = Xv.parse(r);
3198
- } catch (r) {
3199
- throw t.warn("Could not handle response", { response: e, err: r, content: await e.text() }), new Error("An unknown problem occurred");
3197
+ n = Xv.parse(JSON.parse(r));
3198
+ } catch (o) {
3199
+ throw t.warn("Could not handle response", { response: e, err: o, content: r }), new Error("An unknown problem occurred");
3200
3200
  }
3201
3201
  throw t.debug("The response indicates a problem", n), new dn(
3202
3202
  n.title,
3203
3203
  n.detail,
3204
3204
  n.status,
3205
- n.errors ? Object.fromEntries(Object.entries(n.errors).map(([r, o]) => [Jv(r), o.join(", ")])) : void 0
3205
+ n.errors ? Object.fromEntries(Object.entries(n.errors).map(([o, s]) => [Jv(o), s.join(", ")])) : void 0
3206
3206
  );
3207
3207
  }
3208
3208
  var lp = {};
@@ -3245,7 +3245,8 @@ var Oi = /* @__PURE__ */ ((e) => (e.iLok = "iLok", e))(Oi || {}), Ku = v.object(
3245
3245
  }), io = v.object({
3246
3246
  id: v.string(),
3247
3247
  email: v.string(),
3248
- name: v.string(),
3248
+ // Nullable: customers created via import may have no name.
3249
+ name: v.string().nullable(),
3249
3250
  tenantId: v.string(),
3250
3251
  address: Ku.optional(),
3251
3252
  phone: v.string().optional(),
@@ -3608,7 +3609,7 @@ vn(yp, {
3608
3609
  milestoneProgressSchema: () => Sp,
3609
3610
  subscriptionSchema: () => ca
3610
3611
  });
3611
- var Hr = /* @__PURE__ */ ((e) => (e.Active = "Active", e.Expired = "Expired", e.Cancelled = "Cancelled", e.Completed = "Completed", e))(Hr || {}), wp = {};
3612
+ var wp = {};
3612
3613
  vn(wp, {
3613
3614
  completedOrderSchema: () => Ap,
3614
3615
  openBundleLineItem: () => Cp,
@@ -3732,7 +3733,7 @@ var Bo = /* @__PURE__ */ ((e) => (e.Open = "Open", e.PaymentProcessing = "Paymen
3732
3733
  )
3733
3734
  }),
3734
3735
  Ap
3735
- ]), Qc = v.object({
3736
+ ]), Hr = /* @__PURE__ */ ((e) => (e.Active = "Active", e.Expired = "Expired", e.Cancelled = "Cancelled", e.Completed = "Completed", e))(Hr || {}), Qc = v.object({
3736
3737
  milestoneId: v.string(),
3737
3738
  fulfilled: v.boolean(),
3738
3739
  afterCycleNumber: v.number(),
@@ -3859,6 +3860,22 @@ var Bo = /* @__PURE__ */ ((e) => (e.Open = "Open", e.PaymentProcessing = "Paymen
3859
3860
  return (await this.api.fetch(`/api/customer/storefront?${t.toString()}`, rp)).data;
3860
3861
  }
3861
3862
  }, mg = class {
3863
+ constructor(e = 2) {
3864
+ this.level = e;
3865
+ }
3866
+ debug(e, ...t) {
3867
+ this.level <= 0 && console.debug(e, ...t);
3868
+ }
3869
+ log(e, ...t) {
3870
+ this.level <= 1 && console.log(e, ...t);
3871
+ }
3872
+ warn(e, ...t) {
3873
+ this.level <= 2 && console.warn(e, ...t);
3874
+ }
3875
+ error(e, ...t) {
3876
+ this.level <= 3 && console.error(e, ...t);
3877
+ }
3878
+ }, vg = class {
3862
3879
  get(e) {
3863
3880
  const t = localStorage.getItem(e);
3864
3881
  return t ? JSON.parse(t) : null;
@@ -3874,7 +3891,7 @@ var Bo = /* @__PURE__ */ ((e) => (e.Open = "Open", e.PaymentProcessing = "Paymen
3874
3891
  n.key === e && t(n.newValue ? JSON.parse(n.newValue) : null);
3875
3892
  });
3876
3893
  }
3877
- }, vg = class {
3894
+ }, gg = class {
3878
3895
  constructor() {
3879
3896
  this.store = {}, this.listeners = {};
3880
3897
  }
@@ -3899,7 +3916,7 @@ var Bo = /* @__PURE__ */ ((e) => (e.Open = "Open", e.PaymentProcessing = "Paymen
3899
3916
  constructor(t) {
3900
3917
  this.configuration = t, this.tokens = null, this.refreshTimeoutId = null, this.refreshPromise = null;
3901
3918
  var n;
3902
- this.store = (n = t.store) != null ? n : typeof window < "u" && localStorage ? new mg() : new vg();
3919
+ this.store = (n = t.store) != null ? n : typeof window < "u" && localStorage ? new vg() : new gg();
3903
3920
  const r = this.store.get(Vs.storageKey);
3904
3921
  r && (this.tokens = {
3905
3922
  ...r,
@@ -3925,7 +3942,8 @@ var Bo = /* @__PURE__ */ ((e) => (e.Open = "Open", e.PaymentProcessing = "Paymen
3925
3942
  setUser(t) {
3926
3943
  const n = t;
3927
3944
  if (!n.accessToken || !n.refreshToken) {
3928
- if (!this.tokens) return null;
3945
+ if (!this.tokens)
3946
+ return null;
3929
3947
  this.tokens = {
3930
3948
  ...t,
3931
3949
  accessToken: this.tokens.accessToken,
@@ -3981,7 +3999,7 @@ var Ip = v.object({
3981
3999
  id: v.string(),
3982
4000
  name: v.string(),
3983
4001
  logoUrl: v.string().nullable()
3984
- }), gg = class {
4002
+ }), bg = class {
3985
4003
  constructor(e) {
3986
4004
  this.api = e;
3987
4005
  }
@@ -4001,7 +4019,7 @@ var gu = v.object({
4001
4019
  redeemsProducts: Gc(Co).array(),
4002
4020
  redeemsBundles: Gc(Ai).array(),
4003
4021
  properties: v.record(ss).nullish()
4004
- }), bg = class {
4022
+ }), yg = class {
4005
4023
  constructor(e) {
4006
4024
  this.api = e;
4007
4025
  }
@@ -4017,22 +4035,6 @@ var gu = v.object({
4017
4035
  }
4018
4036
  )).data;
4019
4037
  }
4020
- }, yg = class {
4021
- constructor(e = 2) {
4022
- this.level = e;
4023
- }
4024
- debug(e, ...t) {
4025
- this.level <= 0 && console.debug(e, ...t);
4026
- }
4027
- log(e, ...t) {
4028
- this.level <= 1 && console.log(e, ...t);
4029
- }
4030
- warn(e, ...t) {
4031
- this.level <= 2 && console.warn(e, ...t);
4032
- }
4033
- error(e, ...t) {
4034
- this.level <= 3 && console.error(e, ...t);
4035
- }
4036
4038
  }, ol = {};
4037
4039
  vn(ol, {
4038
4040
  activationRequests: () => Gf,
@@ -4072,7 +4074,7 @@ var sl = class {
4072
4074
  }, Hn = class Mp {
4073
4075
  static eligible(t, n) {
4074
4076
  switch (t.condition.type) {
4075
- case "CartContainsItems":
4077
+ case "CartContainsItems": {
4076
4078
  const r = n.items.filter(
4077
4079
  (s) => s.type === "Product" && t.condition.relevantItemVariations[`Product/${s.productId}`] && t.condition.relevantItemVariations[`Product/${s.productId}`].includes(s.variationId) || s.type === "Bundle" && t.condition.relevantItemVariations[`Bundle/${s.bundleId}`] && t.condition.relevantItemVariations[`Bundle/${s.bundleId}`].includes(s.variationId)
4078
4080
  ), o = n.items.flatMap((s) => {
@@ -4083,6 +4085,7 @@ var sl = class {
4083
4085
  return t.condition.relevantItemVariations[`Product/${i}`] && t.condition.relevantItemVariations[`Product/${i}`].includes(a);
4084
4086
  });
4085
4087
  return r.length + o.length >= t.condition.minimumItems;
4088
+ }
4086
4089
  }
4087
4090
  return console.warn("Unsupported offer condition found:", t.condition), !1;
4088
4091
  }
@@ -4105,7 +4108,8 @@ var sl = class {
4105
4108
  };
4106
4109
  }
4107
4110
  static targetContainsBundle(t, n) {
4108
- if (Array.isArray(t.target)) return t.target.some((r) => r.type === "Bundle" && r.id === n);
4111
+ if (Array.isArray(t.target))
4112
+ return t.target.some((r) => r.type === "Bundle" && r.id === n);
4109
4113
  }
4110
4114
  };
4111
4115
  function wg(e, t) {
@@ -4123,7 +4127,7 @@ function _g(e, t) {
4123
4127
  var kg = class {
4124
4128
  constructor(e) {
4125
4129
  var t;
4126
- this.configuration = e, this.configuration.endpoint = this.configuration.endpoint.replace(/\/$/, ""), this.logger = (t = this.configuration.logger) != null ? t : new yg(), this.tokenStore = new Np(e), this.api = new ag(this.configuration.endpoint, this.tokenStore, this.logger), this.storefront = new hg(this.api, this.configuration), this.identity = new eg(this.api, this.tokenStore, this.logger), this.communications = new Qv(this.api), this.vouchers = new bg(this.api), this.orders = new pg(this.api), this.inventory = new fg(this.api, this.configuration), this.activationRequests = new Gv(this.api), this.vendor = new gg(this.api);
4130
+ this.configuration = e, this.configuration.endpoint = this.configuration.endpoint.replace(/\/$/, ""), this.logger = (t = this.configuration.logger) != null ? t : new mg(), this.tokenStore = new Np(e), this.api = new ag(this.configuration.endpoint, this.tokenStore, this.logger), this.storefront = new hg(this.api, this.configuration), this.identity = new eg(this.api, this.tokenStore, this.logger), this.communications = new Qv(this.api), this.vouchers = new yg(this.api), this.orders = new pg(this.api), this.inventory = new fg(this.api, this.configuration), this.activationRequests = new Gv(this.api), this.vendor = new bg(this.api);
4127
4131
  }
4128
4132
  }, Vp = {};
4129
4133
  /**
@@ -14590,9 +14594,9 @@ const An = /* @__PURE__ */ _r(k2, [["render", x2]]), C2 = ["data-visible", "data
14590
14594
  }, [
14591
14595
  y(An, null, {
14592
14596
  default: E(() => {
14593
- var _;
14597
+ var _, T;
14594
14598
  return [
14595
- O($((_ = g(r).user.value) == null ? void 0 : _.name), 1)
14599
+ O($(((_ = g(r).user.value) == null ? void 0 : _.name) || ((T = g(r).user.value) == null ? void 0 : T.email)), 1)
14596
14600
  ];
14597
14601
  }),
14598
14602
  _: 1
@@ -14816,7 +14820,7 @@ function Y2() {
14816
14820
  if (P.dataset.moonbaseOriginal === void 0 && (P.dataset.moonbaseOriginal = P.textContent || ""), B)
14817
14821
  switch (P.dataset.moonbaseRender) {
14818
14822
  case "user.name":
14819
- P.textContent = B.name;
14823
+ P.textContent = B.name ?? B.email;
14820
14824
  break;
14821
14825
  case "user.email":
14822
14826
  P.textContent = B.email;
@@ -17774,7 +17778,7 @@ const be = /* @__PURE__ */ _r(u5, [["render", d5]]), f5 = { class: "moonbase:abo
17774
17778
  }, h5 = /* @__PURE__ */ ae({
17775
17779
  __name: "About",
17776
17780
  setup(e) {
17777
- const t = we(), n = typeof window < "u" && window.__moonbaseTestVersionOverride || "2.5.1", r = W(() => {
17781
+ const t = we(), n = typeof window < "u" && window.__moonbaseTestVersionOverride || "2.5.2", r = W(() => {
17778
17782
  const o = n.match(/-(next)-/);
17779
17783
  if (o)
17780
17784
  return o[1];
@@ -19021,7 +19025,7 @@ const Ht = /* @__PURE__ */ _r(J5, [["render", tx]]), nx = ["data-corners"], rx =
19021
19025
  i.value ? (h(), k("div", Rx, [
19022
19026
  y(Et)
19023
19027
  ])) : a.value ? (h(), k("div", Lx, $(a.value), 1)) : (h(), k(oe, { key: 2 }, [
19024
- j("h3", null, " Hi " + $((c = g(o)) == null ? void 0 : c.name) + ", ", 1),
19028
+ j("h3", null, " Hi " + $(((c = g(o)) == null ? void 0 : c.name) || "there") + ", ", 1),
19025
19029
  u[0] || (u[0] = j("p", null, " Thanks for confirming your new email. You can now sign in using this new address. ", -1))
19026
19030
  ], 64))
19027
19031
  ]);
@@ -22975,15 +22979,19 @@ const OA = { class: "moonbase:product-downloads" }, SA = ["data-open"], PA = {
22975
22979
  )
22976
22980
  ), B = W(() => {
22977
22981
  const w = (t.product.downloads ?? []).filter((N) => N.platform === b);
22978
- if (w.length === 0) return /* @__PURE__ */ new Set();
22982
+ if (w.length === 0)
22983
+ return /* @__PURE__ */ new Set();
22979
22984
  const D = Math.min(...w.map(M));
22980
22985
  return new Set(w.filter((N) => M(N) === D));
22981
22986
  });
22982
22987
  function P(w) {
22983
- if (!w.arch || w.arch === Nt.Universal || w.arch === Nt.Unknown) return null;
22988
+ if (!w.arch || w.arch === Nt.Universal || w.arch === Nt.Unknown)
22989
+ return null;
22984
22990
  if (w.platform === ln.Mac) {
22985
- if (w.arch === Nt.Arm64) return "Apple Silicon";
22986
- if (w.arch === Nt.X64) return "Intel";
22991
+ if (w.arch === Nt.Arm64)
22992
+ return "Apple Silicon";
22993
+ if (w.arch === Nt.X64)
22994
+ return "Intel";
22987
22995
  }
22988
22996
  switch (w.arch) {
22989
22997
  case Nt.X86:
@@ -24439,9 +24447,9 @@ function jO(e) {
24439
24447
  Currency: o.order.currency
24440
24448
  });
24441
24449
  })), t.push(Ge(Oe.SignedIn, (o) => {
24442
- r({ email: o.user.email, name: o.user.name, id: o.user.id });
24450
+ r({ email: o.user.email, name: o.user.name ?? void 0, id: o.user.id });
24443
24451
  })), t.push(Ge(Oe.SignedUp, (o) => {
24444
- r({ email: o.user.email, name: o.user.name, id: o.user.id });
24452
+ r({ email: o.user.email, name: o.user.name ?? void 0, id: o.user.id });
24445
24453
  })), t.push(Ge(Oe.SignedOut, () => {
24446
24454
  Ee("Klaviyo: sign-out received; onsite profile persists (no identify reset API)");
24447
24455
  }));