@weaverse/hydrogen 5.21.0 → 5.21.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.js CHANGED
@@ -1365,6 +1365,8 @@ var SMART_CACHE_STRATEGIES = {
1365
1365
  staleIfError: CACHE_DURATIONS.LONG
1366
1366
  }
1367
1367
  };
1368
+ var bodyFreeCacheRequests = /* @__PURE__ */ new WeakSet();
1369
+ var BODY_FREE_CACHE_SENTINEL = "\0weaverse:body-free";
1368
1370
  var WeaverseClient = class {
1369
1371
  /** Builder API version used by this client. */
1370
1372
  API = API_PATH;
@@ -1748,7 +1750,12 @@ var WeaverseClient = class {
1748
1750
  "weaverse-fetch",
1749
1751
  url,
1750
1752
  options.method || "GET",
1751
- fetchOptions.body,
1753
+ bodyFreeCacheRequests.has(options) ? BODY_FREE_CACHE_SENTINEL : fetchOptions.body,
1754
+ // WeakSet-derived discriminator: this slot cannot be produced by any
1755
+ // caller-supplied shape, so no external call can reach the marked
1756
+ // identity — even one that happens to send the sentinel string as its
1757
+ // body.
1758
+ bodyFreeCacheRequests.has(options),
1752
1759
  this.configs.projectId,
1753
1760
  cacheTarget || "default"
1754
1761
  ];
@@ -1767,6 +1774,19 @@ var WeaverseClient = class {
1767
1774
  }
1768
1775
  return result.data;
1769
1776
  };
1777
+ /**
1778
+ * Safe origin of the incoming storefront request: scheme, host and explicit
1779
+ * port. Userinfo, path, query and fragment are dropped, so no customer
1780
+ * route or credential-bearing value leaves the storefront. Returns undefined
1781
+ * for a non-http(s) request so the field is simply omitted.
1782
+ */
1783
+ safeStorefrontOrigin() {
1784
+ const { protocol, host } = this.parsedUrl;
1785
+ if (protocol !== "http:" && protocol !== "https:") {
1786
+ return;
1787
+ }
1788
+ return host ? `${protocol}//${host}` : void 0;
1789
+ }
1770
1790
  /**
1771
1791
  * Load theme settings from Weaverse API with fallback to schema defaults.
1772
1792
  * Merges remote settings with local theme schema and handles design mode serialization.
@@ -1789,19 +1809,25 @@ var WeaverseClient = class {
1789
1809
  throw new Error("Missing Weaverse projectId!");
1790
1810
  }
1791
1811
  const url = this.getApiUrl("project_configs");
1792
- const body = JSON.stringify({ isDesignMode, projectId });
1812
+ const body = JSON.stringify({
1813
+ isDesignMode,
1814
+ projectId,
1815
+ storefrontUrl: this.safeStorefrontOrigin()
1816
+ });
1817
+ const themeSettingsOptions = {
1818
+ method: "POST",
1819
+ cacheTarget: "theme-settings",
1820
+ strategy,
1821
+ body,
1822
+ headers: {
1823
+ "Content-Type": "application/json",
1824
+ Accept: "application/json",
1825
+ "Accept-Encoding": "gzip, deflate, br"
1826
+ }
1827
+ };
1828
+ bodyFreeCacheRequests.add(themeSettingsOptions);
1793
1829
  const [data, merchantOverrides] = await Promise.all([
1794
- this.fetchWithCache(url, {
1795
- method: "POST",
1796
- cacheTarget: "theme-settings",
1797
- strategy,
1798
- body,
1799
- headers: {
1800
- "Content-Type": "application/json",
1801
- Accept: "application/json",
1802
- "Accept-Encoding": "gzip, deflate, br"
1803
- }
1804
- }),
1830
+ this.fetchWithCache(url, themeSettingsOptions),
1805
1831
  this.fetchMerchantOverrides(strategy)
1806
1832
  ]);
1807
1833
  let result = data;
@@ -2177,66 +2203,6 @@ function getSelectedProductOptions(request) {
2177
2203
  ({ name }) => name !== "isDesignMode" && !name.startsWith("weaverse")
2178
2204
  );
2179
2205
  }
2180
- var IMAGES_PLACEHOLDERS = {
2181
- /** White Weaverse logo placeholder. */
2182
- logo_white: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-logo-w-600x200.svg",
2183
- /** Black Weaverse logo placeholder. */
2184
- logo_black: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-logo-k-600x200.svg",
2185
- /** Generic square image placeholder. */
2186
- image: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-image-1024x1024.svg",
2187
- /** First landscape banner placeholder. */
2188
- banner_1: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-lifestyle-1-1800x900.svg",
2189
- /** Second landscape banner placeholder. */
2190
- banner_2: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-lifestyle-2-1800x900.svg",
2191
- /** Hats collection placeholder. */
2192
- collection_1: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-collection-hats-1024x1024.svg",
2193
- /** Shoes collection placeholder. */
2194
- collection_2: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-collection-shoes-1024x1024.svg",
2195
- /** Glasses collection placeholder. */
2196
- collection_3: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-collection-glasses-1024x1024.svg",
2197
- /** Lamps collection placeholder. */
2198
- collection_4: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-collection-lamps-1024x1024.svg",
2199
- /** Bags collection placeholder. */
2200
- collection_5: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-collection-bags-1024x1024.svg",
2201
- /** Watches collection placeholder. */
2202
- collection_6: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-collection-watches-1024x1024.svg",
2203
- /** Third watch product placeholder. */
2204
- product_1: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-watch-3-1024x1024.svg",
2205
- /** Second bag product placeholder. */
2206
- product_2: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-bag-2-1024x1024.svg",
2207
- /** First shoe product placeholder. */
2208
- product_3: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-shoe-1-1024x1024.svg",
2209
- /** Second lamp product placeholder. */
2210
- product_4: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-lamp-2-1024x1024.svg",
2211
- /** First glasses product placeholder. */
2212
- product_5: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-glasses-1-1024x1024.svg",
2213
- /** First lamp product placeholder. */
2214
- product_6: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-lamp-1-1024x1024.svg",
2215
- /** Second glasses product placeholder. */
2216
- product_7: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-glasses-2-1024x1024.svg",
2217
- /** Third hat product placeholder. */
2218
- product_8: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-hat-3-1024x1024.svg",
2219
- /** First bag product placeholder. */
2220
- product_9: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-bag-1-1024x1024.svg",
2221
- /** Second shoe product placeholder. */
2222
- product_10: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-shoe-2-1024x1024.svg",
2223
- /** Second hat product placeholder. */
2224
- product_11: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-hat-2-1024x1024.svg",
2225
- /** Third glasses product placeholder. */
2226
- product_12: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-glasses-3-1024x1024.svg",
2227
- /** Third shoe product placeholder. */
2228
- product_13: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-shoe-3-1024x1024.svg",
2229
- /** Third bag product placeholder. */
2230
- product_14: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-bag-3-1024x1024.svg",
2231
- /** First hat product placeholder. */
2232
- product_15: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-hat-1-1024x1024.svg",
2233
- /** Third lamp product placeholder. */
2234
- product_16: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-lamp-3-1024x1024.svg",
2235
- /** First watch product placeholder. */
2236
- product_17: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-watch-1-1024x1024.svg",
2237
- /** Second watch product placeholder. */
2238
- product_18: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-watch-2-1024x1024.svg"
2239
- };
2240
2206
 
2241
2207
  Object.defineProperty(exports, "isBrowser", {
2242
2208
  enumerable: true,
@@ -2262,7 +2228,6 @@ Object.defineProperty(exports, "useWeaverse", {
2262
2228
  enumerable: true,
2263
2229
  get: function () { return react.useWeaverse; }
2264
2230
  });
2265
- exports.IMAGES_PLACEHOLDERS = IMAGES_PLACEHOLDERS;
2266
2231
  exports.ThemeTextProvider = ThemeTextProvider;
2267
2232
  exports.ThemeTextStore = ThemeTextStore;
2268
2233
  exports.TranslationProvider = TranslationProvider;