@swell/apps-sdk 1.0.174 → 1.0.176

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
@@ -50,7 +50,7 @@ __export(index_exports, {
50
50
  GEO_DATA: () => GEO_DATA,
51
51
  HtmlCache: () => HtmlCache,
52
52
  LANG_TO_COUNTRY_CODES: () => LANG_TO_COUNTRY_CODES,
53
- LiquidSwell: () => LiquidSwell30,
53
+ LiquidSwell: () => LiquidSwell31,
54
54
  MAX_QUERY_PAGE_LIMIT: () => MAX_QUERY_PAGE_LIMIT,
55
55
  MockRecordResource: () => MockRecordResource,
56
56
  MockRecordSingleton: () => MockRecordSingleton,
@@ -4020,7 +4020,7 @@ var Cache = class {
4020
4020
  /**
4021
4021
  * Always fetches fresh data and updates cache
4022
4022
  * Deduplicates concurrent requests with the same key
4023
- *
4023
+ *
4024
4024
  * @param key Cache key
4025
4025
  * @param fetchFn Function to fetch fresh data
4026
4026
  * @param ttl Time to live in milliseconds (default: DEFAULT_SWR_TTL)
@@ -4766,8 +4766,8 @@ var SORT_OPTIONS = Object.freeze([
4766
4766
  { value: "popularity", name: "Popularity", query: "popularity desc" },
4767
4767
  { value: "price_asc", name: "Price, low to high", query: "price asc" },
4768
4768
  { value: "price_desc", name: "Price, high to low", query: "price desc" },
4769
- { value: "date_asc", name: "Date, old to new", query: "date asc" },
4770
- { value: "date_desc", name: "Date, new to old", query: "date desc" },
4769
+ { value: "date_asc", name: "Date, old to new", query: "date_created asc" },
4770
+ { value: "date_desc", name: "Date, new to old", query: "date_created desc" },
4771
4771
  { value: "name_asc", name: "Product name, A-Z", query: "name asc" },
4772
4772
  { value: "name_desc", name: "Product name, Z-A", query: "name desc" }
4773
4773
  ]);
@@ -5560,23 +5560,58 @@ function getBlog(swell, id, query) {
5560
5560
  // src/easyblocks/config.ts
5561
5561
  var import_json53 = __toESM(require("json5"), 1);
5562
5562
  var import_lodash_es4 = require("lodash-es");
5563
+
5564
+ // src/compatibility/drops/template.ts
5565
+ var import_liquidjs3 = require("liquidjs");
5566
+ var TemplateDrop = class extends import_liquidjs3.Drop {
5567
+ constructor(name, directory, suffix) {
5568
+ super();
5569
+ this.name = name;
5570
+ this.directory = directory;
5571
+ this.suffix = suffix;
5572
+ }
5573
+ valueOf() {
5574
+ return this.name;
5575
+ }
5576
+ };
5577
+
5578
+ // src/compatibility/shopify-objects/template.ts
5579
+ function ShopifyTemplate(instance, template) {
5580
+ return new TemplateDrop(
5581
+ instance.getPageType(template.name),
5582
+ template.path,
5583
+ template.alt_name
5584
+ );
5585
+ }
5586
+
5587
+ // src/easyblocks/config.ts
5563
5588
  var NO_INLINE = true;
5564
5589
  async function getEasyblocksPageTemplate(theme, pageId, altTemplate) {
5565
5590
  let templateConfig = null;
5591
+ let templateData = {
5592
+ name: pageId
5593
+ };
5594
+ if (theme.shopifyCompatibility) {
5595
+ templateData = ShopifyTemplate(theme.shopifyCompatibility, templateData);
5596
+ }
5597
+ const { name } = templateData;
5566
5598
  templateConfig = await theme.getThemeTemplateConfigByType(
5567
5599
  "templates",
5568
- pageId,
5600
+ name,
5569
5601
  altTemplate
5570
5602
  );
5571
5603
  if (templateConfig) {
5572
- if (templateConfig.file_path.endsWith(".liquid")) {
5573
- return templateConfig.file_data;
5604
+ let result = templateConfig.file_data;
5605
+ if (!templateConfig.file_path.endsWith(".liquid")) {
5606
+ try {
5607
+ result = import_json53.default.parse(templateConfig.file_data);
5608
+ } catch {
5609
+ }
5574
5610
  }
5575
- try {
5576
- return import_json53.default.parse(templateConfig.file_data);
5577
- } catch {
5578
- return templateConfig.file_data;
5611
+ if (result && typeof result === "object") {
5612
+ result.id = name;
5579
5613
  }
5614
+ return result;
5580
5615
  }
5581
5616
  }
5582
5617
  function getAcceptedLayoutSections(allSections, groupType) {
@@ -11518,11 +11553,11 @@ __export(shopify_objects_exports, {
11518
11553
  });
11519
11554
 
11520
11555
  // src/compatibility/drops/image.ts
11521
- var import_liquidjs4 = require("liquidjs");
11556
+ var import_liquidjs5 = require("liquidjs");
11522
11557
 
11523
11558
  // src/compatibility/drops/image-src.ts
11524
- var import_liquidjs3 = require("liquidjs");
11525
- var ImageSrcDrop = class extends import_liquidjs3.Drop {
11559
+ var import_liquidjs4 = require("liquidjs");
11560
+ var ImageSrcDrop = class extends import_liquidjs4.Drop {
11526
11561
  constructor(url, width, height) {
11527
11562
  super();
11528
11563
  this.url = url;
@@ -11545,7 +11580,7 @@ var ImageSrcDrop = class extends import_liquidjs3.Drop {
11545
11580
  };
11546
11581
 
11547
11582
  // src/compatibility/drops/image.ts
11548
- var ImageDrop = class extends import_liquidjs4.Drop {
11583
+ var ImageDrop = class extends import_liquidjs5.Drop {
11549
11584
  id;
11550
11585
  alt;
11551
11586
  src;
@@ -11756,7 +11791,9 @@ function ShopifyVariant(instance, variant, productIn, depth = 0) {
11756
11791
  ),
11757
11792
  barcode: void 0,
11758
11793
  compare_at_price: defer(
11759
- () => instance.toShopifyPrice(variant.orig_price)
11794
+ () => instance.toShopifyPrice(
11795
+ getPriceField(product, variant, "orig_price")
11796
+ )
11760
11797
  ),
11761
11798
  featured_image: deferWith(
11762
11799
  [product, variant],
@@ -11803,13 +11840,14 @@ function ShopifyVariant(instance, variant, productIn, depth = 0) {
11803
11840
  // Deprecated by Shopify
11804
11841
  option3: getOptionByIndex(product, variant, 2),
11805
11842
  // Deprecated by Shopify
11806
- price: deferWith([product, variant], (product2, variant2) => {
11807
- let price = product2.price;
11808
- if (variant2.price !== null && variant2.price !== void 0) {
11809
- price = variant2.price;
11843
+ price: deferWith(
11844
+ [product, variant],
11845
+ (product2, variant2) => {
11846
+ return instance.toShopifyPrice(
11847
+ getPriceField(product2, variant2, "price")
11848
+ );
11810
11849
  }
11811
- return instance.toShopifyPrice(price);
11812
- }),
11850
+ ),
11813
11851
  product: deferWith(product, (product2) => {
11814
11852
  return ShopifyProduct(
11815
11853
  instance,
@@ -11848,7 +11886,11 @@ function ShopifyVariant(instance, variant, productIn, depth = 0) {
11848
11886
  store_availabilities: [],
11849
11887
  taxable: true,
11850
11888
  title: defer(() => variant.name),
11851
- unit_price: defer(() => instance.toShopifyPrice(variant.price)),
11889
+ unit_price: defer(
11890
+ () => instance.toShopifyPrice(
11891
+ getPriceField(product, variant, "price")
11892
+ )
11893
+ ),
11852
11894
  unit_price_measurement: void 0,
11853
11895
  url: defer(() => product.url),
11854
11896
  weight: defer(() => variant.weight),
@@ -11872,6 +11914,9 @@ function getOptions(product, variant) {
11872
11914
  return variant2.option_value_ids.map((id) => optionValuesById[id]).filter(Boolean);
11873
11915
  });
11874
11916
  }
11917
+ function getPriceField(product, variant, field) {
11918
+ return variant[field] ?? product[field];
11919
+ }
11875
11920
  function getOptionByIndex(product, variant, index) {
11876
11921
  return deferWith(
11877
11922
  [product, variant],
@@ -12299,7 +12344,12 @@ function ShopifyProduct(instance, product, depth = 0) {
12299
12344
  return instance.toShopifyPrice(product2.price);
12300
12345
  }
12301
12346
  const max = product2.variants.results.reduce(
12302
- (max2, variant) => Math.max(max2, variant.price),
12347
+ (max2, variant) => {
12348
+ if (variant.price === void 0 || variant.price === null) {
12349
+ return max2;
12350
+ }
12351
+ return Math.max(max2, variant.price);
12352
+ },
12303
12353
  0
12304
12354
  );
12305
12355
  return instance.toShopifyPrice(max);
@@ -12309,7 +12359,12 @@ function ShopifyProduct(instance, product, depth = 0) {
12309
12359
  return instance.toShopifyPrice(product2.price);
12310
12360
  }
12311
12361
  const min = product2.variants.results.reduce(
12312
- (min2, variant) => Math.min(min2, variant.price),
12362
+ (min2, variant) => {
12363
+ if (variant.price === void 0 || variant.price === null) {
12364
+ return min2;
12365
+ }
12366
+ return Math.min(min2, variant.price);
12367
+ },
12313
12368
  Infinity
12314
12369
  );
12315
12370
  return instance.toShopifyPrice(min);
@@ -12319,7 +12374,7 @@ function ShopifyProduct(instance, product, depth = 0) {
12319
12374
  return false;
12320
12375
  }
12321
12376
  return product2.variants.results.some(
12322
- (variant) => variant.price !== product2.price
12377
+ (variant) => variant.price !== void 0 && variant.price !== null && variant.price !== product2.price
12323
12378
  );
12324
12379
  }),
12325
12380
  published_at: deferWith(
@@ -13058,8 +13113,8 @@ function ShopifyShippingMethod(instance, order) {
13058
13113
  }
13059
13114
 
13060
13115
  // src/compatibility/drops/money.ts
13061
- var import_liquidjs5 = require("liquidjs");
13062
- var MoneyDrop = class extends import_liquidjs5.Drop {
13116
+ var import_liquidjs6 = require("liquidjs");
13117
+ var MoneyDrop = class extends import_liquidjs6.Drop {
13063
13118
  constructor(value, decimals, currency) {
13064
13119
  super();
13065
13120
  this.value = value;
@@ -13652,8 +13707,8 @@ function ShopifyShop(instance, store) {
13652
13707
  }
13653
13708
 
13654
13709
  // src/compatibility/drops/all_products.ts
13655
- var import_liquidjs6 = require("liquidjs");
13656
- var AllProductsDrop = class extends import_liquidjs6.Drop {
13710
+ var import_liquidjs7 = require("liquidjs");
13711
+ var AllProductsDrop = class extends import_liquidjs7.Drop {
13657
13712
  #instance;
13658
13713
  #map;
13659
13714
  constructor(instance) {
@@ -13695,8 +13750,8 @@ var AllProductsDrop = class extends import_liquidjs6.Drop {
13695
13750
  };
13696
13751
 
13697
13752
  // src/compatibility/drops/articles.ts
13698
- var import_liquidjs7 = require("liquidjs");
13699
- var ArticlesDrop = class extends import_liquidjs7.Drop {
13753
+ var import_liquidjs8 = require("liquidjs");
13754
+ var ArticlesDrop = class extends import_liquidjs8.Drop {
13700
13755
  #instance;
13701
13756
  #map;
13702
13757
  constructor(instance) {
@@ -13738,8 +13793,8 @@ var ArticlesDrop = class extends import_liquidjs7.Drop {
13738
13793
  };
13739
13794
 
13740
13795
  // src/compatibility/drops/blogs.ts
13741
- var import_liquidjs8 = require("liquidjs");
13742
- var BlogsDrop = class extends import_liquidjs8.Drop {
13796
+ var import_liquidjs9 = require("liquidjs");
13797
+ var BlogsDrop = class extends import_liquidjs9.Drop {
13743
13798
  #instance;
13744
13799
  #map;
13745
13800
  constructor(instance) {
@@ -13785,7 +13840,7 @@ var BlogsDrop = class extends import_liquidjs8.Drop {
13785
13840
  };
13786
13841
 
13787
13842
  // src/compatibility/drops/collections.ts
13788
- var import_liquidjs9 = require("liquidjs");
13843
+ var import_liquidjs10 = require("liquidjs");
13789
13844
  var AllCategoryResource = class extends StorefrontResource {
13790
13845
  constructor(instance) {
13791
13846
  super(() => {
@@ -13799,7 +13854,7 @@ var AllCategoryResource = class extends StorefrontResource {
13799
13854
  });
13800
13855
  }
13801
13856
  };
13802
- var CollectionsDrop = class extends import_liquidjs9.Drop {
13857
+ var CollectionsDrop = class extends import_liquidjs10.Drop {
13803
13858
  #instance;
13804
13859
  #map;
13805
13860
  constructor(instance) {
@@ -13916,8 +13971,8 @@ var SwellStorefrontProducts = class extends SwellStorefrontCollection {
13916
13971
  };
13917
13972
 
13918
13973
  // src/compatibility/drops/images.ts
13919
- var import_liquidjs10 = require("liquidjs");
13920
- var ImagesDrop = class extends import_liquidjs10.Drop {
13974
+ var import_liquidjs11 = require("liquidjs");
13975
+ var ImagesDrop = class extends import_liquidjs11.Drop {
13921
13976
  #instance;
13922
13977
  #map;
13923
13978
  constructor(instance) {
@@ -13971,8 +14026,8 @@ var SwellImage = class extends StorefrontResource {
13971
14026
  };
13972
14027
 
13973
14028
  // src/compatibility/drops/object-handles.ts
13974
- var import_liquidjs11 = require("liquidjs");
13975
- var ObjectHandlesDrop = class extends import_liquidjs11.Drop {
14029
+ var import_liquidjs12 = require("liquidjs");
14030
+ var ObjectHandlesDrop = class extends import_liquidjs12.Drop {
13976
14031
  #map;
13977
14032
  constructor(map) {
13978
14033
  super();
@@ -14012,8 +14067,8 @@ var ObjectHandlesDrop = class extends import_liquidjs11.Drop {
14012
14067
  };
14013
14068
 
14014
14069
  // src/compatibility/drops/pages.ts
14015
- var import_liquidjs12 = require("liquidjs");
14016
- var PagesDrop = class extends import_liquidjs12.Drop {
14070
+ var import_liquidjs13 = require("liquidjs");
14071
+ var PagesDrop = class extends import_liquidjs13.Drop {
14017
14072
  #instance;
14018
14073
  #map;
14019
14074
  constructor(instance) {
@@ -14712,29 +14767,6 @@ ${injects.join("\n")}</script>`;
14712
14767
  }
14713
14768
  };
14714
14769
 
14715
- // src/compatibility/drops/template.ts
14716
- var import_liquidjs13 = require("liquidjs");
14717
- var TemplateDrop = class extends import_liquidjs13.Drop {
14718
- constructor(name, directory, suffix) {
14719
- super();
14720
- this.name = name;
14721
- this.directory = directory;
14722
- this.suffix = suffix;
14723
- }
14724
- valueOf() {
14725
- return this.name;
14726
- }
14727
- };
14728
-
14729
- // src/compatibility/shopify-objects/template.ts
14730
- function ShopifyTemplate(instance, template) {
14731
- return new TemplateDrop(
14732
- instance.getPageType(template.name),
14733
- template.path,
14734
- template.alt_name
14735
- );
14736
- }
14737
-
14738
14770
  // src/liquid/drops/render.ts
14739
14771
  var import_liquidjs14 = require("liquidjs");
14740
14772
  var import_lodash_es8 = require("lodash-es");
@@ -14766,6 +14798,14 @@ var RenderDrop = class extends import_liquidjs14.Drop {
14766
14798
  // src/liquid/index.ts
14767
14799
  var import_liquidjs34 = require("liquidjs");
14768
14800
 
14801
+ // src/utils/escape.ts
14802
+ function replacerUnescape(match) {
14803
+ return match.includes('\\"') ? JSON.parse(`"${match}"`) : match;
14804
+ }
14805
+ function unescapeLiquidSyntax(template) {
14806
+ return template.replace(/\{\{.*?\}\}/g, replacerUnescape);
14807
+ }
14808
+
14769
14809
  // src/liquid/tags/assign.ts
14770
14810
  var import_liquidjs15 = require("liquidjs");
14771
14811
  function bind(_liquidSwell) {
@@ -15274,28 +15314,30 @@ var import_liquidjs24 = require("liquidjs");
15274
15314
  function bind10(liquidSwell) {
15275
15315
  return class RenderTag extends import_liquidjs24.RenderTag {
15276
15316
  *render(ctx, emitter) {
15277
- const { liquid, hash } = this;
15278
- const filepath = yield renderFilePath(
15279
- this["file"],
15317
+ const self = this;
15318
+ const { liquid } = this;
15319
+ const { hash } = self;
15320
+ const filename = yield renderFilePath(
15321
+ self["file"],
15280
15322
  ctx,
15281
15323
  liquid
15282
15324
  );
15283
- (0, import_liquidjs24.assert)(filepath, () => `illegal file path "${filepath}"`);
15284
- const themeConfig = yield liquidSwell.getComponentPath(filepath).then(
15285
- (fileName) => liquidSwell.getThemeConfig(fileName)
15325
+ (0, import_liquidjs24.assert)(filename, () => `illegal file path "${filename}"`);
15326
+ const configPath = yield liquidSwell.getComponentPath(
15327
+ filename
15286
15328
  );
15287
15329
  const childCtx = ctx.spawn();
15288
15330
  const scope = childCtx.bottom();
15289
15331
  (0, import_lodash_es9.assign)(scope, yield hash.render(ctx));
15290
15332
  const parentSection = yield ctx._get(["section"]);
15291
15333
  if (parentSection) (0, import_lodash_es9.assign)(scope, { section: parentSection });
15292
- if (this["with"]) {
15293
- const { value, alias } = this["with"];
15294
- const aliasName = alias || filepath;
15334
+ if (self["with"]) {
15335
+ const { value, alias } = self["with"];
15336
+ const aliasName = alias || filename;
15295
15337
  scope[aliasName] = yield (0, import_liquidjs24.evalToken)(value, ctx);
15296
15338
  }
15297
- if (this["for"]) {
15298
- const { value, alias } = this["for"];
15339
+ if (self["for"]) {
15340
+ const { value, alias } = self["for"];
15299
15341
  let collection = yield (0, import_liquidjs24.evalToken)(value, ctx);
15300
15342
  collection = yield resolveEnumerable(collection);
15301
15343
  scope["forloop"] = new ForloopDrop(
@@ -15305,13 +15347,23 @@ function bind10(liquidSwell) {
15305
15347
  );
15306
15348
  for (const item of collection) {
15307
15349
  scope[alias] = item;
15308
- const output = yield liquidSwell.renderTemplate(themeConfig, scope);
15309
- emitter.write(output);
15350
+ const templates = yield liquid._parseFile(
15351
+ configPath,
15352
+ childCtx.sync,
15353
+ void 0,
15354
+ self["currentFile"]
15355
+ );
15356
+ yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
15310
15357
  scope["forloop"].next();
15311
15358
  }
15312
15359
  } else {
15313
- const output = yield liquidSwell.renderTemplate(themeConfig, scope);
15314
- emitter.write(output);
15360
+ const templates = yield liquid._parseFile(
15361
+ configPath,
15362
+ childCtx.sync,
15363
+ void 0,
15364
+ self["currentFile"]
15365
+ );
15366
+ yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
15315
15367
  }
15316
15368
  }
15317
15369
  };
@@ -15373,12 +15425,12 @@ function bind11(liquidSwell) {
15373
15425
  });
15374
15426
  });
15375
15427
  if (output && schema && settings) {
15376
- const { shopify_compatibility: shopifyCompatibility } = liquidSwell.theme.globals;
15377
15428
  const tag = schema.tag || "div";
15378
- const id = `${shopifyCompatibility ? "shopify" : "swell"}-section-${settings.id || this.fileName}`;
15379
- const className = shopifyCompatibility ? "shopify-section" : "swell-section";
15429
+ const sectionClassName = liquidSwell.theme.getSectionClassName();
15430
+ const sectionIdPrefix = liquidSwell.theme.getSectionIdPrefix();
15431
+ const id = `${sectionIdPrefix}-${settings.id || this.fileName}`;
15380
15432
  emitter.write(
15381
- `<${tag} id="${id}" class="${className} ${schema.class || ""}">${output}</${tag}>`
15433
+ `<${tag} id="${id}" class="${sectionClassName} ${schema.class || ""}">${output}</${tag}>`
15382
15434
  );
15383
15435
  }
15384
15436
  }
@@ -15410,12 +15462,13 @@ function bind12(liquidSwell) {
15410
15462
  const sectionConfigs = yield liquidSwell.renderPageSections(
15411
15463
  sectionGroup
15412
15464
  );
15413
- const { shopify_compatibility: shopifyCompatibility } = liquidSwell.theme.globals;
15465
+ const sectionClassName = liquidSwell.theme.getSectionClassName();
15466
+ const sectionIdPrefix = liquidSwell.theme.getSectionIdPrefix();
15414
15467
  emitter.write(
15415
15468
  `<div id="swell-section-group__${this.fileName}">${sectionConfigs.map((section) => {
15416
15469
  const tag = section.tag || "div";
15417
- const id = `${shopifyCompatibility ? "shopify" : "swell"}-section-sections--${themeConfig.hash}__${section.id}`;
15418
- const className = shopifyCompatibility ? `shopify-section shopify-section-group-${this.fileName} section-${section.id}` : `swell-section swell-section-group-${this.fileName} section-${section.id}`;
15470
+ const id = `${sectionIdPrefix}-sections--${themeConfig.hash}__${section.id}`;
15471
+ const className = `${sectionClassName} ${sectionClassName}-group-${this.fileName} section-${section.id}`;
15419
15472
  return `<${tag} id="${id}" class="${className} ${section.class || ""}">${section.output}</${tag}>`;
15420
15473
  }).join("")}</div>`
15421
15474
  );
@@ -15600,7 +15653,7 @@ var tags = {
15600
15653
  };
15601
15654
  function bindTags(liquidSwell) {
15602
15655
  Object.entries(tags).forEach(
15603
- ([tag, bind65]) => liquidSwell.registerTag(tag, bind65(liquidSwell))
15656
+ ([tag, bind66]) => liquidSwell.registerTag(tag, bind66(liquidSwell))
15604
15657
  );
15605
15658
  }
15606
15659
 
@@ -16153,8 +16206,17 @@ function bind46(_liquidSwell) {
16153
16206
  };
16154
16207
  }
16155
16208
 
16209
+ // src/liquid/filters/minus.ts
16210
+ function bind47(_liquidSwell) {
16211
+ return (first, second) => {
16212
+ const firstValue = isNumber(first) ? first : 0;
16213
+ const secondValue = isNumber(second) ? second : 0;
16214
+ return firstValue - secondValue;
16215
+ };
16216
+ }
16217
+
16156
16218
  // src/liquid/filters/money.ts
16157
- function bind47(liquidSwell) {
16219
+ function bind48(liquidSwell) {
16158
16220
  return function filterMoney(value) {
16159
16221
  const amount = getMoneyAmount(liquidSwell, value);
16160
16222
  return liquidSwell.renderCurrency(amount);
@@ -16171,7 +16233,7 @@ function getMoneyAmount(liquidSwell, value) {
16171
16233
  }
16172
16234
 
16173
16235
  // src/liquid/filters/money_with_currency.ts
16174
- function bind48(liquidSwell) {
16236
+ function bind49(liquidSwell) {
16175
16237
  return function filterMoneyWithCurrency(value) {
16176
16238
  const { currency } = liquidSwell.theme.swell.getStorefrontLocalization();
16177
16239
  const amount = getMoneyAmount(liquidSwell, value);
@@ -16180,7 +16242,7 @@ function bind48(liquidSwell) {
16180
16242
  }
16181
16243
 
16182
16244
  // src/liquid/filters/money_without_currency.ts
16183
- function bind49(liquidSwell) {
16245
+ function bind50(liquidSwell) {
16184
16246
  return function filterMoneyWithoutCurrency(value) {
16185
16247
  const amount = getMoneyAmount(liquidSwell, value);
16186
16248
  return liquidSwell.renderCurrency(amount).replace(/[^0-9.,]/g, "");
@@ -16188,7 +16250,7 @@ function bind49(liquidSwell) {
16188
16250
  }
16189
16251
 
16190
16252
  // src/liquid/filters/money_without_trailing_zeros.ts
16191
- function bind50(liquidSwell) {
16253
+ function bind51(liquidSwell) {
16192
16254
  return function filterMoneyWithoutTrailingZeros(value) {
16193
16255
  const amount = getMoneyAmount(liquidSwell, value);
16194
16256
  return liquidSwell.renderCurrency(amount).split(".")[0].split(",")[0];
@@ -16196,21 +16258,21 @@ function bind50(liquidSwell) {
16196
16258
  }
16197
16259
 
16198
16260
  // src/liquid/filters/script_tag.ts
16199
- function bind51(_liquidSwell) {
16261
+ function bind52(_liquidSwell) {
16200
16262
  return function filterScriptTag(assetUrl) {
16201
16263
  return `<script src="${assetUrl}" type="text/javascript"></script>`;
16202
16264
  };
16203
16265
  }
16204
16266
 
16205
16267
  // src/liquid/filters/stylesheet_tag.ts
16206
- function bind52(_liquidSwell) {
16268
+ function bind53(_liquidSwell) {
16207
16269
  return function filterStyleSheetTag(assetUrl) {
16208
16270
  return `<link href="${assetUrl}" rel="stylesheet" type="text/css" media="all" />`;
16209
16271
  };
16210
16272
  }
16211
16273
 
16212
16274
  // src/liquid/filters/time_tag.ts
16213
- function bind53(_liquidSwell) {
16275
+ function bind54(_liquidSwell) {
16214
16276
  const dateFilter = bind33(_liquidSwell);
16215
16277
  return (dateValue, ...params) => {
16216
16278
  const date = ensureDate(dateValue);
@@ -16221,7 +16283,7 @@ function bind53(_liquidSwell) {
16221
16283
  }
16222
16284
 
16223
16285
  // src/liquid/filters/translate.ts
16224
- function bind54(liquidSwell) {
16286
+ function bind55(liquidSwell) {
16225
16287
  return async function filterTranslate(key, params) {
16226
16288
  const props = params && paramsToProps(params);
16227
16289
  const str = await liquidSwell.renderTranslation(key, props);
@@ -16230,7 +16292,7 @@ function bind54(liquidSwell) {
16230
16292
  }
16231
16293
 
16232
16294
  // src/liquid/filters/where.ts
16233
- function bind55(_liquidSwell) {
16295
+ function bind56(_liquidSwell) {
16234
16296
  return function* filterWhere(arr, property, expected) {
16235
16297
  const results = [];
16236
16298
  const list = yield resolveEnumerable(arr);
@@ -16284,7 +16346,7 @@ function getSizesFromParam(param) {
16284
16346
  height: height ? Number(height) : void 0
16285
16347
  };
16286
16348
  }
16287
- function bind56(liquidSwell) {
16349
+ function bind57(liquidSwell) {
16288
16350
  return async function filterAssetImgUrl(assetPath, size = "small") {
16289
16351
  const imageUrl = await liquidSwell.getAssetUrl(assetPath).then((url) => url || "");
16290
16352
  const sizes = getSizesFromParam(size);
@@ -16300,14 +16362,14 @@ function bind56(liquidSwell) {
16300
16362
  }
16301
16363
 
16302
16364
  // src/liquid/filters/shopify/hex_to_rgba.ts
16303
- function bind57(_liquidSwell) {
16365
+ function bind58(_liquidSwell) {
16304
16366
  return (color, alpha) => {
16305
16367
  return ThemeColor.get(color).rgba(alpha || 1);
16306
16368
  };
16307
16369
  }
16308
16370
 
16309
16371
  // src/liquid/filters/shopify/img_url.ts
16310
- function bind58(_liquidSwell) {
16372
+ function bind59(_liquidSwell) {
16311
16373
  return function filterImgUrl(input, ...params) {
16312
16374
  if (!input) return "";
16313
16375
  let url;
@@ -16352,14 +16414,14 @@ var item_count_for_variant_default = {
16352
16414
  };
16353
16415
 
16354
16416
  // src/liquid/filters/shopify/payment_button.ts
16355
- function bind59(_liquidSwell) {
16417
+ function bind60(_liquidSwell) {
16356
16418
  return (form) => {
16357
16419
  return null;
16358
16420
  };
16359
16421
  }
16360
16422
 
16361
16423
  // src/liquid/filters/shopify/payment_terms.ts
16362
- function bind60(_liquidSwell) {
16424
+ function bind61(_liquidSwell) {
16363
16425
  return (form) => {
16364
16426
  return null;
16365
16427
  };
@@ -16461,7 +16523,7 @@ var svgs = {
16461
16523
  var placeholder_svgs_default = svgs;
16462
16524
 
16463
16525
  // src/liquid/filters/shopify/placeholder_svg_tag.ts
16464
- function bind61(_liquidSwell) {
16526
+ function bind62(_liquidSwell) {
16465
16527
  return function filterPlaceholderSvgTag(name, className) {
16466
16528
  const svg = placeholder_svgs_default[name];
16467
16529
  if (typeof svg === "object" && svg !== null) {
@@ -16472,7 +16534,7 @@ function bind61(_liquidSwell) {
16472
16534
  }
16473
16535
 
16474
16536
  // src/liquid/filters/shopify/shopify_asset_url.ts
16475
- function bind62(_liquidSwell) {
16537
+ function bind63(_liquidSwell) {
16476
16538
  return function filterShopifyAssetUrl(input) {
16477
16539
  if (typeof input === "string") {
16478
16540
  switch (input) {
@@ -16497,7 +16559,7 @@ function bind62(_liquidSwell) {
16497
16559
  }
16498
16560
 
16499
16561
  // src/liquid/filters/shopify/structured_data.ts
16500
- function bind63(_liquidSwell) {
16562
+ function bind64(_liquidSwell) {
16501
16563
  return async function filterStructuredData(input) {
16502
16564
  let value = input;
16503
16565
  if (value instanceof StorefrontResource) {
@@ -16575,7 +16637,7 @@ function convertToSchemaOrgProductGroup(product) {
16575
16637
  }
16576
16638
 
16577
16639
  // src/liquid/filters/inline_editable.ts
16578
- function bind64(_liquidSwell) {
16640
+ function bind65(_liquidSwell) {
16579
16641
  return (value, key) => {
16580
16642
  if (typeof value === "object" && "value" in value) {
16581
16643
  value = value.value;
@@ -16619,29 +16681,30 @@ var filters = {
16619
16681
  json: bind44,
16620
16682
  json_pretty: bind45,
16621
16683
  locale_flag: bind46,
16622
- money: bind47,
16623
- money_with_currency: bind48,
16624
- money_without_currency: bind49,
16625
- money_without_trailing_zeros: bind50,
16626
- script_tag: bind51,
16627
- stylesheet_tag: bind52,
16628
- time_tag: bind53,
16629
- translate: bind54,
16630
- t: bind54,
16684
+ minus: bind47,
16685
+ money: bind48,
16686
+ money_with_currency: bind49,
16687
+ money_without_currency: bind50,
16688
+ money_without_trailing_zeros: bind51,
16689
+ script_tag: bind52,
16690
+ stylesheet_tag: bind53,
16691
+ time_tag: bind54,
16692
+ translate: bind55,
16693
+ t: bind55,
16631
16694
  // alias
16632
- where: bind55,
16695
+ where: bind56,
16633
16696
  // Shopify compatibility only
16634
- asset_img_url: bind56,
16635
- hex_to_rgba: bind57,
16636
- img_url: bind58,
16697
+ asset_img_url: bind57,
16698
+ hex_to_rgba: bind58,
16699
+ img_url: bind59,
16637
16700
  item_count_for_variant: item_count_for_variant_default,
16638
- payment_button: bind59,
16639
- payment_terms: bind60,
16640
- placeholder_svg_tag: bind61,
16641
- shopify_asset_url: bind62,
16642
- structured_data: bind63,
16701
+ payment_button: bind60,
16702
+ payment_terms: bind61,
16703
+ placeholder_svg_tag: bind62,
16704
+ shopify_asset_url: bind63,
16705
+ structured_data: bind64,
16643
16706
  // Swell only
16644
- inline_editable: bind64
16707
+ inline_editable: bind65
16645
16708
  };
16646
16709
  function bindFilters(liquidSwell) {
16647
16710
  for (const [tag, handler] of Object.entries(filters)) {
@@ -16655,8 +16718,8 @@ function bindFilters(liquidSwell) {
16655
16718
  }
16656
16719
  }
16657
16720
  }
16658
- function bindWithResolvedProps(liquidSwell, bind65, resolve = []) {
16659
- const handler = bind65(liquidSwell);
16721
+ function bindWithResolvedProps(liquidSwell, bind66, resolve = []) {
16722
+ const handler = bind66(liquidSwell);
16660
16723
  if (!Array.isArray(resolve)) {
16661
16724
  return handler;
16662
16725
  }
@@ -16718,7 +16781,8 @@ var swellOperators = {
16718
16781
  if (isArray(l)) return l.some((i) => equal(i, r));
16719
16782
  if (isFunction(l?.indexOf)) return l.indexOf(toValue(r)) > -1;
16720
16783
  return false;
16721
- }
16784
+ },
16785
+ ",": (l, r) => `${l},${r}`
16722
16786
  };
16723
16787
  function equal(lhs, rhs) {
16724
16788
  if (isComparable(lhs)) return lhs.equals(rhs);
@@ -16873,7 +16937,7 @@ function isThemeColorLike(value) {
16873
16937
  }
16874
16938
 
16875
16939
  // src/liquid/index.ts
16876
- var LiquidSwell30 = class extends import_liquidjs34.Liquid {
16940
+ var LiquidSwell31 = class extends import_liquidjs34.Liquid {
16877
16941
  theme;
16878
16942
  getThemeConfig;
16879
16943
  getThemeTemplateConfigByType;
@@ -16911,13 +16975,15 @@ var LiquidSwell30 = class extends import_liquidjs34.Liquid {
16911
16975
  }) {
16912
16976
  getThemeConfig = getThemeConfig || theme.getThemeConfig.bind(theme);
16913
16977
  extName = extName || "liquid";
16978
+ const fs = new LiquidFS(extName);
16914
16979
  super({
16915
- cache: false,
16980
+ cache: true,
16916
16981
  relativeReference: false,
16917
- fs: getLiquidFS(getThemeConfig, extName),
16982
+ fs,
16918
16983
  ownPropertyOnly: false,
16919
16984
  operators: swellOperators
16920
16985
  });
16986
+ fs.liquidSwell = this;
16921
16987
  this.theme = theme;
16922
16988
  this.getThemeConfig = getThemeConfig;
16923
16989
  this.getThemeTemplateConfigByType = getThemeTemplateConfigByType || theme.getThemeTemplateConfigByType.bind(theme);
@@ -16960,41 +17026,36 @@ var LiquidSwell30 = class extends import_liquidjs34.Liquid {
16960
17026
  function resolveFilePath(fileName, extName) {
16961
17027
  return `theme/${fileName}.${extName}`;
16962
17028
  }
16963
- function getLiquidFS(getThemeConfig, extName) {
16964
- return {
16965
- /** read a file asynchronously */
16966
- async readFile(filePath) {
16967
- const resolvedPath = resolveFilePath(filePath, extName);
16968
- return getThemeConfig(resolvedPath).then(
16969
- (template) => template?.file_data || `<!-- theme template not found: ${resolvedPath} -->`
16970
- );
16971
- },
16972
- /** check if a file exists asynchronously */
16973
- async exists(_filePath) {
16974
- return true;
16975
- },
16976
- /** read a file synchronously */
16977
- readFileSync(_filePath) {
16978
- return "";
16979
- },
16980
- /** check if a file exists synchronously */
16981
- existsSync(_filePath) {
16982
- return false;
16983
- },
16984
- /** check if file is contained in `root`, always return `true` by default. Warning: not setting this could expose path traversal vulnerabilities. */
16985
- contains(_root, _file) {
16986
- return true;
16987
- },
16988
- /** resolve a file against directory, for given `ext` option */
16989
- resolve(_dir, file, _ext) {
16990
- return file;
16991
- },
16992
- /** fallback file for lookup failure */
16993
- fallback(_filePath) {
16994
- return;
16995
- }
16996
- };
16997
- }
17029
+ var LiquidFS = class {
17030
+ liquidSwell;
17031
+ constructor(_extName) {
17032
+ }
17033
+ async readFile(filePath) {
17034
+ const template = await this.liquidSwell.getThemeConfig(filePath);
17035
+ return unescapeLiquidSyntax(
17036
+ template?.file_data || `<!-- theme template not found: ${filePath} -->`
17037
+ );
17038
+ }
17039
+ async exists(filePath) {
17040
+ const template = await this.liquidSwell.getThemeConfig(filePath);
17041
+ return Boolean(template);
17042
+ }
17043
+ readFileSync(_filePath) {
17044
+ return "";
17045
+ }
17046
+ existsSync(_filePath) {
17047
+ return false;
17048
+ }
17049
+ contains(_root, _file) {
17050
+ return true;
17051
+ }
17052
+ resolve(_dir, file, _ext) {
17053
+ return file;
17054
+ }
17055
+ fallback(_filePath) {
17056
+ return;
17057
+ }
17058
+ };
16998
17059
 
16999
17060
  // src/theme/theme-loader.ts
17000
17061
  var MAX_INDIVIDUAL_CONFIGS_TO_FETCH = 50;
@@ -17550,7 +17611,7 @@ var SwellTheme3 = class {
17550
17611
  this.resources = resources;
17551
17612
  this.dynamicAssetUrl = dynamicAssetUrl;
17552
17613
  this.shopifyCompatibilityClass = shopifyCompatibilityClass || ShopifyCompatibility2;
17553
- this.liquidSwell = new LiquidSwell30({
17614
+ this.liquidSwell = new LiquidSwell31({
17554
17615
  theme: this,
17555
17616
  getThemeConfig: this.getThemeConfig.bind(this),
17556
17617
  getAssetUrl: this.getAssetUrl.bind(this),
@@ -18468,6 +18529,12 @@ ${content.slice(pos)}`;
18468
18529
  isShopify1HomePage(pageId, pageContent) {
18469
18530
  return Boolean(pageId === "index" && typeof pageContent === "string");
18470
18531
  }
18532
+ getSectionClassName() {
18533
+ return this.shopifyCompatibility ? "shopify-section" : "swell-section";
18534
+ }
18535
+ getSectionIdPrefix() {
18536
+ return this.shopifyCompatibility ? "shopify-section" : "swell-section";
18537
+ }
18471
18538
  async renderAllSections(sectionsIds, pageData) {
18472
18539
  const sections = typeof sectionsIds === "string" ? sectionsIds.split(/\s*,\s*/) : sectionsIds;
18473
18540
  const sectionsRendered = await Promise.all(
@@ -18475,18 +18542,14 @@ ${content.slice(pos)}`;
18475
18542
  return this.renderSection(sectionId, pageData);
18476
18543
  })
18477
18544
  );
18545
+ const sectionClassName = this.getSectionClassName();
18546
+ const sectionIdPrefix = this.getSectionIdPrefix();
18478
18547
  return sectionsRendered.reduce(
18479
18548
  (acc, section, index) => {
18480
18549
  const sectionId = sections[index];
18481
- if (this.shopifyCompatibility) {
18482
- acc[sectionId] = `
18483
- <div id="shopify-section-${sectionId}" class="shopify-section">${String(section)}</div>
18484
- `.trim();
18485
- } else {
18486
- acc[sectionId] = `
18487
- <div id="swell-section-${sectionId}" class="swell-section">${String(section)}</div>
18550
+ acc[sectionId] = `
18551
+ <div id="${sectionIdPrefix}-${sectionId}" class="${sectionClassName}">${String(section)}</div>
18488
18552
  `.trim();
18489
- }
18490
18553
  return acc;
18491
18554
  },
18492
18555
  {}
@@ -19018,12 +19081,6 @@ function parseJsonConfig(config) {
19018
19081
  return {};
19019
19082
  }
19020
19083
  }
19021
- function replacerUnescape(match) {
19022
- return match.includes('\\"') ? JSON.parse(`"${match}"`) : match;
19023
- }
19024
- function unescapeLiquidSyntax(template) {
19025
- return template.replace(/\{\{.*?\}\}/g, replacerUnescape);
19026
- }
19027
19084
  function extractSchemaTag(template) {
19028
19085
  const list = template.match(
19029
19086
  /\{%-?\s*schema\s*-?%\}(.*)\{%-?\s*endschema\s*-?%\}/s