@numueg/theme-sdk 0.5.0 → 0.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/dist/index.cjs CHANGED
@@ -9,7 +9,7 @@ var MAX_BLOCK_DEPTH = 5;
9
9
 
10
10
  // src/validation/index.ts
11
11
  var THEME_CONTRACT_VERSION = 1;
12
- var SDK_VERSION = "0.5.0" ;
12
+ var SDK_VERSION = "0.5.2" ;
13
13
  var REQUIRED_TEMPLATES = [
14
14
  "home",
15
15
  "product",
@@ -709,7 +709,7 @@ function useOrder(id) {
709
709
  const [tick, setTick] = react.useState(0);
710
710
  react.useEffect(() => {
711
711
  if (typeof window === "undefined") return;
712
- if (!customer || !id) {
712
+ if (!id) {
713
713
  setOrder(null);
714
714
  setError(null);
715
715
  setLoading(false);
@@ -720,14 +720,15 @@ function useOrder(id) {
720
720
  setError(null);
721
721
  void (async () => {
722
722
  try {
723
- const res = await fetch(
724
- `/api/customer/me/orders/${encodeURIComponent(id)}`,
725
- {
726
- method: "GET",
727
- credentials: "include",
728
- cache: "no-store"
729
- }
730
- );
723
+ const trackUrl = `/api/storefront/track/${encodeURIComponent(id)}`;
724
+ let res = customer ? await fetch(`/api/customer/me/orders/${encodeURIComponent(id)}`, {
725
+ method: "GET",
726
+ credentials: "include",
727
+ cache: "no-store"
728
+ }) : await fetch(trackUrl, { cache: "no-store" });
729
+ if (!res.ok && customer) {
730
+ res = await fetch(trackUrl, { cache: "no-store" });
731
+ }
731
732
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
732
733
  const body = unwrap(await res.json());
733
734
  if (cancelled) return;
@@ -1469,16 +1470,17 @@ function availableValues(product, selection) {
1469
1470
  const variants = product.variants || [];
1470
1471
  const out = {};
1471
1472
  for (const axis of axes) {
1472
- out[axis.name] = /* @__PURE__ */ new Set();
1473
+ const set = /* @__PURE__ */ new Set();
1473
1474
  for (const v of variants) {
1474
1475
  const opts = v.option_values || v.options || {};
1475
1476
  const compatible = Object.entries(selection).every(
1476
1477
  ([k, val]) => k === axis.name || opts[k] === val
1477
1478
  );
1478
1479
  if (compatible && opts[axis.name]) {
1479
- out[axis.name].add(opts[axis.name]);
1480
+ set.add(opts[axis.name]);
1480
1481
  }
1481
1482
  }
1483
+ out[axis.name] = set.size > 0 ? set : new Set(axis.values || []);
1482
1484
  }
1483
1485
  return out;
1484
1486
  }