@swell/apps-sdk 1.0.139 → 1.0.141

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
@@ -149,31 +149,44 @@ var import_cache_manager = require("cache-manager");
149
149
 
150
150
  // src/cache/cf-worker-kv-keyv-adapter.ts
151
151
  var CFWorkerKVKeyvAdapter = class {
152
+ store;
152
153
  namespace;
153
154
  // magically passed in from Keyv
154
- store;
155
+ opts;
155
156
  constructor(store) {
156
157
  this.store = store;
158
+ this.opts = null;
157
159
  this.namespace = "dummy";
158
160
  }
159
161
  async has(key) {
160
- return this.get(key) !== void 0;
162
+ const stream = await this.store.get(key, "stream");
163
+ if (stream !== null) {
164
+ await stream.cancel();
165
+ return true;
166
+ }
167
+ return false;
161
168
  }
162
169
  async get(key) {
163
- return this.store.get(key);
170
+ const value = await this.store.get(key);
171
+ return value !== null ? value : void 0;
164
172
  }
165
- async set(key, value) {
166
- return this.store.put(key, value);
173
+ set(key, value, ttl) {
174
+ if (typeof ttl === "number") {
175
+ ttl = Math.max(60, ttl / 1e3);
176
+ }
177
+ return this.store.put(key, value, { expirationTtl: ttl });
167
178
  }
168
179
  async delete(key) {
169
180
  await this.store.delete(key);
181
+ return true;
170
182
  }
171
183
  async clear() {
172
184
  let cursor = "";
173
185
  let complete = false;
174
- while (!complete) {
186
+ const prefix = `${this.namespace}:`;
187
+ do {
175
188
  const response = await this.store.list({
176
- prefix: `${this.namespace}:`,
189
+ prefix,
177
190
  cursor: cursor || void 0
178
191
  });
179
192
  cursor = response.cursor ?? "";
@@ -185,7 +198,10 @@ var CFWorkerKVKeyvAdapter = class {
185
198
  })
186
199
  );
187
200
  }
188
- }
201
+ } while (!complete);
202
+ }
203
+ on(_event, _listener) {
204
+ return this;
189
205
  }
190
206
  };
191
207
 
@@ -7089,23 +7105,25 @@ var Cache = class {
7089
7105
  ...options
7090
7106
  });
7091
7107
  }
7092
- async fetch(key, fetchFn) {
7093
- return this.client.wrap(key, fetchFn);
7108
+ async fetch(key, fetchFn, ttl) {
7109
+ return this.client.wrap(key, fetchFn, ttl);
7094
7110
  }
7095
- // Fetch cache using SWR (stale-while-revalidate)
7096
- // This will always return the cached value immediately if exists
7111
+ /**
7112
+ * Fetch cache using SWR (stale-while-revalidate)
7113
+ *
7114
+ * This will always return the cached value immediately if exists
7115
+ */
7097
7116
  async fetchSWR(key, fetchFn, ttl = DEFAULT_SWR_TTL) {
7098
7117
  const cacheValue = await this.client.get(key);
7099
- const promiseValue = Promise.resolve().then(() => fetchFn()).then(async (value) => {
7118
+ const promiseValue = Promise.resolve().then(fetchFn).then(resolveAsyncResources).then(async (value) => {
7100
7119
  const isNull = value === null || value === void 0;
7101
- const valueResolved = await resolveAsyncResources(value);
7102
- await this.client.set(key, isNull ? NULL_VALUE : valueResolved, ttl);
7120
+ await this.client.set(key, isNull ? NULL_VALUE : value, ttl);
7103
7121
  return value;
7104
7122
  });
7105
7123
  if (this.workerCtx?.waitUntil) {
7106
7124
  this.workerCtx.waitUntil(promiseValue);
7107
7125
  }
7108
- if (cacheValue !== null) {
7126
+ if (cacheValue !== void 0) {
7109
7127
  return cacheValue === NULL_VALUE ? null : cacheValue;
7110
7128
  }
7111
7129
  const result = await promiseValue;
@@ -7122,8 +7140,9 @@ var Cache = class {
7122
7140
  }
7123
7141
  /**
7124
7142
  * Flushes the entire cache.
7125
- * WARNING: If the cache store is shared among many cache clients,
7126
- * this will flush entries for other clients.
7143
+ *
7144
+ * __WARNING__: If the cache store is shared among many cache clients,
7145
+ * this will flush entries for other clients.
7127
7146
  */
7128
7147
  async flushAll() {
7129
7148
  await this.client.clear();
@@ -7166,7 +7185,7 @@ var ResourceCache = class extends Cache {
7166
7185
  function buildStores2() {
7167
7186
  return [
7168
7187
  new import_keyv2.Keyv({
7169
- // Disabling serialization allows for pure memo-ization of class instances
7188
+ // Disabling serialization allows for pure memoization of class instances
7170
7189
  // at the tradeoff of no support for compression.
7171
7190
  serialize: void 0,
7172
7191
  deserialize: void 0
@@ -8706,11 +8725,11 @@ function getRandomId() {
8706
8725
  }
8707
8726
 
8708
8727
  // src/menus.ts
8709
- var import_lodash_es11 = require("lodash-es");
8728
+ var import_lodash_es12 = require("lodash-es");
8710
8729
 
8711
8730
  // src/theme.ts
8712
8731
  var import_json56 = __toESM(require("json5"), 1);
8713
- var import_lodash_es10 = require("lodash-es");
8732
+ var import_lodash_es11 = require("lodash-es");
8714
8733
 
8715
8734
  // src/compatibility/shopify.ts
8716
8735
  var import_lodash_es7 = require("lodash-es");
@@ -17530,7 +17549,7 @@ var tags = {
17530
17549
  };
17531
17550
  function bindTags(liquidSwell) {
17532
17551
  Object.entries(tags).forEach(
17533
- ([tag, bind62]) => liquidSwell.registerTag(tag, bind62(liquidSwell))
17552
+ ([tag, bind63]) => liquidSwell.registerTag(tag, bind63(liquidSwell))
17534
17553
  );
17535
17554
  }
17536
17555
 
@@ -17814,8 +17833,16 @@ var format_address_default = {
17814
17833
  ]
17815
17834
  };
17816
17835
 
17817
- // src/liquid/filters/image_tag.ts
17836
+ // src/liquid/filters/handleize.ts
17837
+ var import_lodash_es10 = require("lodash-es");
17818
17838
  function bind40(_liquidSwell) {
17839
+ return function filterHandleize(handle) {
17840
+ return (0, import_lodash_es10.kebabCase)(handle);
17841
+ };
17842
+ }
17843
+
17844
+ // src/liquid/filters/image_tag.ts
17845
+ function bind41(_liquidSwell) {
17819
17846
  return function filterImageTag(imageUrl, ...params) {
17820
17847
  imageUrl = String(imageUrl || "");
17821
17848
  let {
@@ -17979,7 +18006,7 @@ var filterDefinition = {
17979
18006
  var image_url_default = filterDefinition;
17980
18007
 
17981
18008
  // src/liquid/filters/inline_asset_content.ts
17982
- function bind41(liquidSwell) {
18009
+ function bind42(liquidSwell) {
17983
18010
  return async (assetPath) => {
17984
18011
  const config = await liquidSwell.theme.getThemeConfig(
17985
18012
  `theme/assets/${assetPath}`
@@ -17989,14 +18016,14 @@ function bind41(liquidSwell) {
17989
18016
  }
17990
18017
 
17991
18018
  // src/liquid/filters/json.ts
17992
- function bind42(_liquidSwell) {
18019
+ function bind43(_liquidSwell) {
17993
18020
  return async function filterJson(input, space = 0) {
17994
18021
  return jsonStringifyAsync(input, space);
17995
18022
  };
17996
18023
  }
17997
18024
 
17998
18025
  // src/liquid/filters/json_pretty.ts
17999
- function bind43(_liquidSwell) {
18026
+ function bind44(_liquidSwell) {
18000
18027
  return async function filterJsonPretty(input, space = 2) {
18001
18028
  const output = await jsonStringifyAsync(input, space);
18002
18029
  return `<pre>${output}</pre>`;
@@ -18013,7 +18040,7 @@ function getCountryCode(localCode) {
18013
18040
  return localCode.toUpperCase();
18014
18041
  }
18015
18042
  }
18016
- function bind44(_liquidSwell) {
18043
+ function bind45(_liquidSwell) {
18017
18044
  return (localeCode) => {
18018
18045
  if (typeof localeCode !== "string") {
18019
18046
  return flags.US;
@@ -18024,7 +18051,7 @@ function bind44(_liquidSwell) {
18024
18051
  }
18025
18052
 
18026
18053
  // src/liquid/filters/money.ts
18027
- function bind45(liquidSwell) {
18054
+ function bind46(liquidSwell) {
18028
18055
  return function filterMoney(value) {
18029
18056
  const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
18030
18057
  return liquidSwell.renderCurrency(amount);
@@ -18032,7 +18059,7 @@ function bind45(liquidSwell) {
18032
18059
  }
18033
18060
 
18034
18061
  // src/liquid/filters/money_with_currency.ts
18035
- function bind46(liquidSwell) {
18062
+ function bind47(liquidSwell) {
18036
18063
  return function filterMoneyWithCurrency(value) {
18037
18064
  const { currency } = liquidSwell.theme.swell.getStorefrontLocalization();
18038
18065
  const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
@@ -18041,7 +18068,7 @@ function bind46(liquidSwell) {
18041
18068
  }
18042
18069
 
18043
18070
  // src/liquid/filters/money_without_currency.ts
18044
- function bind47(liquidSwell) {
18071
+ function bind48(liquidSwell) {
18045
18072
  return function filterMoneyWithoutCurrency(value) {
18046
18073
  const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
18047
18074
  return liquidSwell.renderCurrency(amount).replace(/[^0-9.,]/g, "");
@@ -18049,7 +18076,7 @@ function bind47(liquidSwell) {
18049
18076
  }
18050
18077
 
18051
18078
  // src/liquid/filters/money_without_trailing_zeros.ts
18052
- function bind48(liquidSwell) {
18079
+ function bind49(liquidSwell) {
18053
18080
  return function filterMoneyWithoutTrailingZeros(value) {
18054
18081
  const amount = value instanceof MoneyDrop ? value.toFloat() : Number(value || 0);
18055
18082
  return liquidSwell.renderCurrency(amount).split(".")[0].split(",")[0];
@@ -18057,21 +18084,21 @@ function bind48(liquidSwell) {
18057
18084
  }
18058
18085
 
18059
18086
  // src/liquid/filters/script_tag.ts
18060
- function bind49(_liquidSwell) {
18087
+ function bind50(_liquidSwell) {
18061
18088
  return function filterScriptTag(assetUrl) {
18062
18089
  return `<script src="${assetUrl}" type="text/javascript"></script>`;
18063
18090
  };
18064
18091
  }
18065
18092
 
18066
18093
  // src/liquid/filters/stylesheet_tag.ts
18067
- function bind50(_liquidSwell) {
18094
+ function bind51(_liquidSwell) {
18068
18095
  return function filterStyleSheetTag(assetUrl) {
18069
18096
  return `<link href="${assetUrl}" rel="stylesheet" type="text/css" media="all" />`;
18070
18097
  };
18071
18098
  }
18072
18099
 
18073
18100
  // src/liquid/filters/time_tag.ts
18074
- function bind51(_liquidSwell) {
18101
+ function bind52(_liquidSwell) {
18075
18102
  const dateFilter = bind33(_liquidSwell);
18076
18103
  return (dateValue, ...params) => {
18077
18104
  const date = ensureDate(dateValue);
@@ -18082,7 +18109,7 @@ function bind51(_liquidSwell) {
18082
18109
  }
18083
18110
 
18084
18111
  // src/liquid/filters/translate.ts
18085
- function bind52(liquidSwell) {
18112
+ function bind53(liquidSwell) {
18086
18113
  return async function filterTranslate(key, params) {
18087
18114
  const props = params && paramsToProps(params);
18088
18115
  const str = await liquidSwell.renderTranslation(key, props);
@@ -18091,7 +18118,7 @@ function bind52(liquidSwell) {
18091
18118
  }
18092
18119
 
18093
18120
  // src/liquid/filters/where.ts
18094
- function bind53(_liquidSwell) {
18121
+ function bind54(_liquidSwell) {
18095
18122
  return function* filterWhere(arr, property, expected) {
18096
18123
  const results = [];
18097
18124
  const list = yield resolveEnumerable(arr);
@@ -18145,7 +18172,7 @@ function getSizesFromParam(param) {
18145
18172
  height: height ? Number(height) : void 0
18146
18173
  };
18147
18174
  }
18148
- function bind54(liquidSwell) {
18175
+ function bind55(liquidSwell) {
18149
18176
  return async function filterAssetImgUrl(assetPath, size = "small") {
18150
18177
  const imageUrl = await liquidSwell.getAssetUrl(assetPath).then((url) => url || "");
18151
18178
  const sizes = getSizesFromParam(size);
@@ -18161,7 +18188,7 @@ function bind54(liquidSwell) {
18161
18188
  }
18162
18189
 
18163
18190
  // src/liquid/filters/shopify/hex_to_rgba.ts
18164
- function bind55(_liquidSwell) {
18191
+ function bind56(_liquidSwell) {
18165
18192
  return (color, alpha) => {
18166
18193
  return ThemeColor.get(color).rgba(alpha || 1);
18167
18194
  };
@@ -18181,14 +18208,14 @@ var item_count_for_variant_default = {
18181
18208
  };
18182
18209
 
18183
18210
  // src/liquid/filters/shopify/payment_button.ts
18184
- function bind56(_liquidSwell) {
18211
+ function bind57(_liquidSwell) {
18185
18212
  return (form) => {
18186
18213
  return null;
18187
18214
  };
18188
18215
  }
18189
18216
 
18190
18217
  // src/liquid/filters/shopify/payment_terms.ts
18191
- function bind57(_liquidSwell) {
18218
+ function bind58(_liquidSwell) {
18192
18219
  return (form) => {
18193
18220
  return null;
18194
18221
  };
@@ -18290,7 +18317,7 @@ var svgs = {
18290
18317
  var placeholder_svgs_default = svgs;
18291
18318
 
18292
18319
  // src/liquid/filters/shopify/placeholder_svg_tag.ts
18293
- function bind58(_liquidSwell) {
18320
+ function bind59(_liquidSwell) {
18294
18321
  return function filterPlaceholderSvgTag(name, className) {
18295
18322
  const svg = placeholder_svgs_default[name];
18296
18323
  if (typeof svg === "object" && svg !== null) {
@@ -18301,7 +18328,7 @@ function bind58(_liquidSwell) {
18301
18328
  }
18302
18329
 
18303
18330
  // src/liquid/filters/shopify/shopify_asset_url.ts
18304
- function bind59(_liquidSwell) {
18331
+ function bind60(_liquidSwell) {
18305
18332
  return function filterShopifyAssetUrl(input) {
18306
18333
  if (typeof input === "string") {
18307
18334
  switch (input) {
@@ -18326,7 +18353,7 @@ function bind59(_liquidSwell) {
18326
18353
  }
18327
18354
 
18328
18355
  // src/liquid/filters/shopify/structured_data.ts
18329
- function bind60(_liquidSwell) {
18356
+ function bind61(_liquidSwell) {
18330
18357
  return async function filterStructuredData(input) {
18331
18358
  let value = input;
18332
18359
  if (value instanceof StorefrontResource) {
@@ -18404,7 +18431,7 @@ function convertToSchemaOrgProductGroup(product) {
18404
18431
  }
18405
18432
 
18406
18433
  // src/liquid/filters/inline_editable.ts
18407
- function bind61(_liquidSwell) {
18434
+ function bind62(_liquidSwell) {
18408
18435
  return (value, key) => {
18409
18436
  if (typeof value === "object" && "value" in value) {
18410
18437
  value = value.value;
@@ -18438,34 +18465,37 @@ var filters = {
18438
18465
  font_modify: bind38,
18439
18466
  font_url: bind39,
18440
18467
  format_address: format_address_default,
18441
- image_tag: bind40,
18468
+ handle: bind40,
18469
+ // alias
18470
+ handleize: bind40,
18471
+ image_tag: bind41,
18442
18472
  image_url: image_url_default,
18443
- inline_asset_content: bind41,
18444
- json: bind42,
18445
- json_pretty: bind43,
18446
- locale_flag: bind44,
18447
- money: bind45,
18448
- money_with_currency: bind46,
18449
- money_without_currency: bind47,
18450
- money_without_trailing_zeros: bind48,
18451
- script_tag: bind49,
18452
- stylesheet_tag: bind50,
18453
- time_tag: bind51,
18454
- translate: bind52,
18455
- t: bind52,
18473
+ inline_asset_content: bind42,
18474
+ json: bind43,
18475
+ json_pretty: bind44,
18476
+ locale_flag: bind45,
18477
+ money: bind46,
18478
+ money_with_currency: bind47,
18479
+ money_without_currency: bind48,
18480
+ money_without_trailing_zeros: bind49,
18481
+ script_tag: bind50,
18482
+ stylesheet_tag: bind51,
18483
+ time_tag: bind52,
18484
+ translate: bind53,
18485
+ t: bind53,
18456
18486
  // alias
18457
- where: bind53,
18487
+ where: bind54,
18458
18488
  // Shopify compatibility only
18459
- asset_img_url: bind54,
18460
- hex_to_rgba: bind55,
18489
+ asset_img_url: bind55,
18490
+ hex_to_rgba: bind56,
18461
18491
  item_count_for_variant: item_count_for_variant_default,
18462
- payment_button: bind56,
18463
- payment_terms: bind57,
18464
- placeholder_svg_tag: bind58,
18465
- shopify_asset_url: bind59,
18466
- structured_data: bind60,
18492
+ payment_button: bind57,
18493
+ payment_terms: bind58,
18494
+ placeholder_svg_tag: bind59,
18495
+ shopify_asset_url: bind60,
18496
+ structured_data: bind61,
18467
18497
  // Swell only
18468
- inline_editable: bind61
18498
+ inline_editable: bind62
18469
18499
  };
18470
18500
  function bindFilters(liquidSwell) {
18471
18501
  for (const [tag, handler] of Object.entries(filters)) {
@@ -18479,8 +18509,8 @@ function bindFilters(liquidSwell) {
18479
18509
  }
18480
18510
  }
18481
18511
  }
18482
- function bindWithResolvedProps(liquidSwell, bind62, resolve = []) {
18483
- const handler = bind62(liquidSwell);
18512
+ function bindWithResolvedProps(liquidSwell, bind63, resolve = []) {
18513
+ const handler = bind63(liquidSwell);
18484
18514
  if (!Array.isArray(resolve)) {
18485
18515
  return handler;
18486
18516
  }
@@ -18924,28 +18954,30 @@ var ThemeLoader = class _ThemeLoader {
18924
18954
  * Fetches a theme config by file path.
18925
18955
  */
18926
18956
  async fetchThemeConfig(filePath) {
18927
- const themeConfig = this.configs.get(filePath);
18928
- if (themeConfig !== void 0) {
18929
- return themeConfig;
18957
+ const config = this.configs.get(filePath);
18958
+ if (config !== void 0) {
18959
+ return config;
18930
18960
  }
18931
18961
  const hash = this.manifest?.get(filePath);
18932
18962
  if (!hash) {
18933
18963
  return null;
18934
18964
  }
18935
18965
  const cache = this.getCache();
18936
- let config = await cache.get(`config:${hash}`);
18937
- if (config) {
18938
- const themeId = this.getThemeId();
18939
- if (themeId && config.file?.url) {
18940
- const fileUrl = await cache.get(
18941
- `file:${themeId}:${config.hash}`
18942
- );
18943
- if (fileUrl) {
18944
- config = { ...config, file: { ...config.file, url: fileUrl } };
18945
- }
18966
+ const themeId = this.getThemeId();
18967
+ const [themeConfig, fileUrl] = await Promise2.all([
18968
+ cache.get(`config:${hash}`),
18969
+ themeId ? cache.get(`file:${themeId}:${hash}`) : void 0
18970
+ ]);
18971
+ if (themeConfig) {
18972
+ let config2 = themeConfig;
18973
+ if (fileUrl && themeConfig.file?.url) {
18974
+ config2 = {
18975
+ ...themeConfig,
18976
+ file: { ...themeConfig.file, url: fileUrl }
18977
+ };
18946
18978
  }
18947
- this.configs.set(filePath, config);
18948
- return config;
18979
+ this.configs.set(filePath, config2);
18980
+ return config2;
18949
18981
  }
18950
18982
  return this.fetchThemeConfigsFromSourceByPath(filePath, hash);
18951
18983
  }
@@ -18994,18 +19026,20 @@ var ThemeLoader = class _ThemeLoader {
18994
19026
  await Promise2.map(
18995
19027
  manifest.values(),
18996
19028
  async (configHash) => {
18997
- let config = await cache.get(`config:${configHash}`);
18998
- if (!config) {
19029
+ const [themeConfig, fileUrl] = await Promise2.all([
19030
+ cache.get(`config:${configHash}`),
19031
+ themeId ? cache.get(`file:${themeId}:${configHash}`) : void 0
19032
+ ]);
19033
+ if (!themeConfig) {
18999
19034
  configHashesUnresolved.push(configHash);
19000
19035
  return;
19001
19036
  }
19002
- if (themeId && config.file?.url) {
19003
- const fileUrl = await cache.get(
19004
- `file:${themeId}:${configHash}`
19005
- );
19006
- if (fileUrl) {
19007
- config = { ...config, file: { ...config.file, url: fileUrl } };
19008
- }
19037
+ let config = themeConfig;
19038
+ if (fileUrl && themeConfig.file?.url) {
19039
+ config = {
19040
+ ...themeConfig,
19041
+ file: { ...themeConfig.file, url: fileUrl }
19042
+ };
19009
19043
  }
19010
19044
  configsByHash.set(config.hash, config);
19011
19045
  this.configs.set(config.file_path, config);
@@ -19389,13 +19423,15 @@ var SwellTheme3 = class {
19389
19423
  const [cart, account] = await Promise.all([
19390
19424
  this.fetchSingletonResourceCached(
19391
19425
  "cart",
19426
+ // The cached cart may be null, but we need the StorefrontResource
19392
19427
  () => this.fetchCart(),
19393
- {}
19428
+ // Default value (always StorefrontResource)
19429
+ () => this.fetchCart()
19394
19430
  ),
19395
19431
  this.fetchSingletonResourceCached(
19396
19432
  "account",
19397
19433
  () => this.fetchAccount(),
19398
- null
19434
+ () => null
19399
19435
  )
19400
19436
  ]);
19401
19437
  if (!cart) {
@@ -19418,13 +19454,14 @@ var SwellTheme3 = class {
19418
19454
  async fetchSingletonResourceCached(key, handler, defaultValue) {
19419
19455
  const cacheKey = this.swell.storefront.session.getCookie();
19420
19456
  if (!cacheKey) {
19421
- return defaultValue;
19457
+ return defaultValue();
19422
19458
  }
19423
- return this.swell.getCachedResource(
19459
+ const result = await this.swell.getCachedResource(
19424
19460
  `${key}-${cacheKey}`,
19425
19461
  [],
19426
- () => handler()
19462
+ handler
19427
19463
  );
19464
+ return result ?? defaultValue();
19428
19465
  }
19429
19466
  async fetchCart() {
19430
19467
  const CartResource = this.resources?.singletons?.cart;
@@ -19565,7 +19602,7 @@ var SwellTheme3 = class {
19565
19602
  return languageConfig;
19566
19603
  }
19567
19604
  const localeShortCode = locale.split("-")[0];
19568
- return (0, import_lodash_es10.reduce)(
19605
+ return (0, import_lodash_es11.reduce)(
19569
19606
  languageConfig,
19570
19607
  (acc, value, key) => {
19571
19608
  if (isObject2(value)) {
@@ -19589,15 +19626,15 @@ var SwellTheme3 = class {
19589
19626
  const translationEnd = translationParts.pop();
19590
19627
  const translationPath = translationParts.join(".");
19591
19628
  const translationConfigGlobal = this.globals.language;
19592
- acc[key] = (0, import_lodash_es10.get)(
19629
+ acc[key] = (0, import_lodash_es11.get)(
19593
19630
  translationConfigGlobal,
19594
19631
  `${translationPath}.$locale.${locale}.${translationEnd}`
19595
- ) || (0, import_lodash_es10.get)(
19632
+ ) || (0, import_lodash_es11.get)(
19596
19633
  translationConfigGlobal,
19597
19634
  `${translationPath}.$locale.${localeShortCode}.${translationEnd}`
19598
- ) || (0, import_lodash_es10.get)(translationConfigGlobal, translationKey) || value;
19635
+ ) || (0, import_lodash_es11.get)(translationConfigGlobal, translationKey) || value;
19599
19636
  } else {
19600
- acc[key] = (0, import_lodash_es10.get)(languageConfig, `$locale.${locale}.${key}`) || (0, import_lodash_es10.get)(languageConfig, `$locale.${localeShortCode}.${key}`) || value;
19637
+ acc[key] = (0, import_lodash_es11.get)(languageConfig, `$locale.${locale}.${key}`) || (0, import_lodash_es11.get)(languageConfig, `$locale.${localeShortCode}.${key}`) || value;
19601
19638
  }
19602
19639
  }
19603
19640
  return acc;
@@ -20385,8 +20422,8 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
20385
20422
  const keyParts = key?.split(".") || [];
20386
20423
  const keyName = keyParts.pop() || "";
20387
20424
  const keyPath = keyParts.join(".");
20388
- const langObject = (0, import_lodash_es10.get)(langConfig, keyPath);
20389
- let localeValue = (0, import_lodash_es10.get)(langObject?.[localeCode], keyName) || (0, import_lodash_es10.get)(langObject?.[localeCode.split("-")[0]], keyName) || langObject?.[keyName];
20425
+ const langObject = (0, import_lodash_es11.get)(langConfig, keyPath);
20426
+ let localeValue = (0, import_lodash_es11.get)(langObject?.[localeCode], keyName) || (0, import_lodash_es11.get)(langObject?.[localeCode.split("-")[0]], keyName) || langObject?.[keyName];
20390
20427
  if (data?.count !== void 0 && localeValue?.one) {
20391
20428
  localeValue = data.count === 1 ? localeValue.one : localeValue.other;
20392
20429
  }
@@ -20465,7 +20502,7 @@ function fillDefaultThemeSettings(themeSettings, editorSchemaSettings) {
20465
20502
  }
20466
20503
  }
20467
20504
  function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
20468
- const settings = (0, import_lodash_es10.cloneDeep)(themeSettings);
20505
+ const settings = (0, import_lodash_es11.cloneDeep)(themeSettings);
20469
20506
  if (settings.$locale) {
20470
20507
  const { locale } = theme.swell.getStorefrontLocalization();
20471
20508
  const localeConfig = settings.$locale[locale] || {};
@@ -20475,16 +20512,16 @@ function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
20475
20512
  }
20476
20513
  }
20477
20514
  }
20478
- (0, import_lodash_es10.each)(settings, (value, key) => {
20515
+ (0, import_lodash_es11.each)(settings, (value, key) => {
20479
20516
  const setting = (editorSchemaSettings && findEditorSetting(editorSchemaSettings, key)) ?? null;
20480
20517
  if (isObject2(value) && !(value instanceof StorefrontResource)) {
20481
20518
  switch (setting?.type) {
20482
20519
  case "color_scheme_group": {
20483
- (0, import_lodash_es10.each)(value, (scheme, schemeId) => {
20520
+ (0, import_lodash_es11.each)(value, (scheme, schemeId) => {
20484
20521
  if (isObject2(scheme) && typeof scheme.settings === "object" && scheme.settings) {
20485
20522
  const settings2 = scheme.settings;
20486
- (0, import_lodash_es10.each)(settings2, (colorValue, colorId) => {
20487
- const fieldDef = (0, import_lodash_es10.find)(setting.fields, { id: colorId });
20523
+ (0, import_lodash_es11.each)(settings2, (colorValue, colorId) => {
20524
+ const fieldDef = (0, import_lodash_es11.find)(setting.fields, { id: colorId });
20488
20525
  if (fieldDef?.type === "color" && colorValue) {
20489
20526
  scheme.id = schemeId;
20490
20527
  settings2[colorId] = new ThemeColor(colorValue);
@@ -20535,7 +20572,7 @@ function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
20535
20572
  }
20536
20573
  function findThemeSettingsByType(type, themeSettings, editorSchemaSettings) {
20537
20574
  const foundSettings = [];
20538
- (0, import_lodash_es10.each)(themeSettings, (value, key) => {
20575
+ (0, import_lodash_es11.each)(themeSettings, (value, key) => {
20539
20576
  if (isObject2(value) && !(value instanceof ThemeFont) && !(value instanceof StorefrontResource)) {
20540
20577
  foundSettings.push(
20541
20578
  ...findThemeSettingsByType(type, value, editorSchemaSettings)
@@ -20666,13 +20703,20 @@ async function resolveMenuItems(theme, menuItems, options) {
20666
20703
  async function resolveMenuItemUrlAndResource(theme, item, options) {
20667
20704
  if (!item) return { url: "#invalid-link-item" };
20668
20705
  if (typeof item === "object" && item !== null) {
20669
- let { url, resource } = await getMenuItemUrlAndResource(theme, item);
20670
- const endsWithSlash = url.slice(-1) === "/";
20671
- if (options?.trailingSlash && !endsWithSlash && url.length > 1) {
20672
- url = url + "/";
20673
- }
20674
- if (!options?.trailingSlash && endsWithSlash && url.length > 1) {
20675
- url = url.slice(0, -1);
20706
+ const { url: itemUrl, resource } = await getMenuItemUrlAndResource(
20707
+ theme,
20708
+ item
20709
+ );
20710
+ let url = itemUrl;
20711
+ if (url.length > 1) {
20712
+ const endsWithSlash = url.endsWith("/");
20713
+ if (options?.trailingSlash) {
20714
+ if (!endsWithSlash) {
20715
+ url = url + "/";
20716
+ }
20717
+ } else if (endsWithSlash) {
20718
+ url = url.slice(0, -1);
20719
+ }
20676
20720
  }
20677
20721
  return { url, resource };
20678
20722
  } else {
@@ -20697,7 +20741,7 @@ function isChildItemActive(items) {
20697
20741
  }
20698
20742
  function getMenuItemValueId(value) {
20699
20743
  const fallback = typeof value === "string" ? value : "";
20700
- const slug = (0, import_lodash_es11.get)(value, "id", (0, import_lodash_es11.get)(value, "slug", fallback)) || "";
20744
+ const slug = (0, import_lodash_es12.get)(value, "id", (0, import_lodash_es12.get)(value, "slug", fallback)) || "";
20701
20745
  return slug;
20702
20746
  }
20703
20747
  async function getMenuItemUrlAndResource(theme, menuItem) {
@@ -20714,43 +20758,40 @@ async function getMenuItemUrlAndResource(theme, menuItem) {
20714
20758
  return {
20715
20759
  url: getMenuItemStorefrontUrl(theme, "index")
20716
20760
  };
20717
- case "category" /* Category */:
20761
+ case "category" /* Category */: {
20718
20762
  if (!id) {
20719
20763
  return {
20720
20764
  url: getMenuItemStorefrontUrl(theme, "categories/index")
20721
20765
  };
20722
20766
  }
20723
- return await deferMenuItemUrlAndResource(
20724
- theme,
20725
- "categories/category",
20726
- id
20727
- );
20728
- case "product" /* Product */:
20767
+ return deferMenuItemUrlAndResource(theme, "categories/category", id);
20768
+ }
20769
+ case "product" /* Product */: {
20729
20770
  if (!id) {
20730
20771
  return {
20731
20772
  url: getMenuItemStorefrontUrl(theme, "products/index")
20732
20773
  };
20733
20774
  }
20734
- return await deferMenuItemUrlAndResource(theme, "products/product", id);
20775
+ return deferMenuItemUrlAndResource(theme, "products/product", id);
20776
+ }
20777
+ case "product_list" /* ProductList */:
20778
+ return {
20779
+ url: getMenuItemStorefrontUrl(theme, "products/index")
20780
+ };
20735
20781
  case "page" /* Page */:
20736
- return await deferMenuItemUrlAndResource(theme, "pages/page", id);
20782
+ return deferMenuItemUrlAndResource(theme, "pages/page", id);
20737
20783
  case "blog" /* Blog */:
20738
- return await deferMenuItemUrlAndResource(
20739
- theme,
20740
- "blogs/blog",
20741
- id,
20742
- async (blog) => {
20743
- const blogCategory = new SwellStorefrontRecord(
20744
- theme.swell,
20745
- "content/blog-categories",
20746
- blog.category_id
20747
- );
20748
- return blogCategory.slug;
20749
- }
20750
- );
20784
+ return deferMenuItemUrlAndResource(theme, "blogs/blog", id, (blog) => {
20785
+ const blogCategory = new SwellStorefrontRecord(
20786
+ theme.swell,
20787
+ "content/blog-categories",
20788
+ blog.category_id
20789
+ );
20790
+ return blogCategory.slug;
20791
+ });
20751
20792
  case "blog_category" /* BlogCategory */:
20752
- return await deferMenuItemUrlAndResource(theme, "blogs/category", id);
20753
- case "content_list" /* ContentList */:
20793
+ return deferMenuItemUrlAndResource(theme, "blogs/category", id);
20794
+ case "content_list" /* ContentList */: {
20754
20795
  if (model) {
20755
20796
  const slug = model?.replace("content/", "");
20756
20797
  return {
@@ -20759,10 +20800,11 @@ async function getMenuItemUrlAndResource(theme, menuItem) {
20759
20800
  };
20760
20801
  }
20761
20802
  break;
20762
- case "content" /* Content */:
20803
+ }
20804
+ case "content" /* Content */: {
20763
20805
  if (model) {
20764
20806
  const collectionSlug = model?.replace("content/", "");
20765
- return await deferMenuItemUrlAndResource(
20807
+ return deferMenuItemUrlAndResource(
20766
20808
  theme,
20767
20809
  "content/content",
20768
20810
  id,
@@ -20770,6 +20812,7 @@ async function getMenuItemUrlAndResource(theme, menuItem) {
20770
20812
  );
20771
20813
  }
20772
20814
  break;
20815
+ }
20773
20816
  case "search" /* Search */:
20774
20817
  return {
20775
20818
  url: getMenuItemStorefrontUrl(theme, "search")