@swell/apps-sdk 1.0.124 → 1.0.126

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
@@ -8161,7 +8161,7 @@ function getEasyblocksPagePropsWithConfigs(themeGlobals, allSections, pageSectio
8161
8161
  {
8162
8162
  _id: "swell_page",
8163
8163
  _component: "swell_page",
8164
- ContentSections: pageSections.filter((config) => componentSet.has(config.section.type)).map(({ section, settings, schema }) => ({
8164
+ [SECTION_GROUP_CONTENT]: pageSections.filter((config) => componentSet.has(config.section.type)).map(({ section, settings, schema }) => ({
8165
8165
  _id: prepareSectionId(section.id),
8166
8166
  _component: section.type,
8167
8167
  custom_css: settings?.section?.custom_css || "",
@@ -13751,7 +13751,10 @@ function ShopifyBlog(instance, blogCategory) {
13751
13751
  blogCategory = cloneStorefrontResource(blogCategory);
13752
13752
  }
13753
13753
  const allTags = deferWith(blogCategory.blogs, (blogs) => {
13754
- const set = blogs?.results?.reduce(
13754
+ if (!Array.isArray(blogs?.results)) {
13755
+ return [];
13756
+ }
13757
+ const set = blogs.results.reduce(
13755
13758
  (set2, blog) => {
13756
13759
  for (const tag of blog.tags || []) {
13757
13760
  set2.add(tag);
@@ -16540,13 +16543,25 @@ function ShopifyTemplate(_instance, template) {
16540
16543
  );
16541
16544
  }
16542
16545
 
16546
+ // src/compatibility/drops/render.ts
16547
+ var import_liquidjs5 = require("liquidjs");
16548
+ var RenderDrop = class extends import_liquidjs5.Drop {
16549
+ constructor(handler) {
16550
+ super();
16551
+ this.handler = handler;
16552
+ }
16553
+ valueOf() {
16554
+ return this.handler();
16555
+ }
16556
+ };
16557
+
16543
16558
  // src/liquid/index.ts
16544
- var import_liquidjs24 = require("liquidjs");
16559
+ var import_liquidjs25 = require("liquidjs");
16545
16560
 
16546
16561
  // src/liquid/tags/assign.ts
16547
- var import_liquidjs5 = require("liquidjs");
16562
+ var import_liquidjs6 = require("liquidjs");
16548
16563
  function bind(_liquidSwell) {
16549
- return class AssignTag extends import_liquidjs5.Tag {
16564
+ return class AssignTag extends import_liquidjs6.Tag {
16550
16565
  key;
16551
16566
  value;
16552
16567
  identifier;
@@ -16558,7 +16573,7 @@ function bind(_liquidSwell) {
16558
16573
  this.tokenizer.skipBlank();
16559
16574
  this.tokenizer.advance();
16560
16575
  try {
16561
- this.value = new import_liquidjs5.Value(this.tokenizer.readFilteredValue(), this.liquid);
16576
+ this.value = new import_liquidjs6.Value(this.tokenizer.readFilteredValue(), this.liquid);
16562
16577
  } catch (e) {
16563
16578
  console.warn(
16564
16579
  `Liquid "assign" tag: ${e instanceof Error ? e.stack : String(e)}`
@@ -16585,9 +16600,9 @@ function bind(_liquidSwell) {
16585
16600
  }
16586
16601
 
16587
16602
  // src/liquid/tags/case.ts
16588
- var import_liquidjs6 = require("liquidjs");
16603
+ var import_liquidjs7 = require("liquidjs");
16589
16604
  function bind2(liquidSwell) {
16590
- return class CaseTag extends import_liquidjs6.Tag {
16605
+ return class CaseTag extends import_liquidjs7.Tag {
16591
16606
  value;
16592
16607
  branches;
16593
16608
  elseTemplates;
@@ -16598,7 +16613,7 @@ function bind2(liquidSwell) {
16598
16613
  const caseVar = this.tokenizer.readValue()?.getText();
16599
16614
  this.isBlock = Boolean(caseVar?.startsWith("block."));
16600
16615
  this.tokenizer.p = begin;
16601
- this.value = new import_liquidjs6.Value(this.tokenizer.readFilteredValue(), this.liquid);
16616
+ this.value = new import_liquidjs7.Value(this.tokenizer.readFilteredValue(), this.liquid);
16602
16617
  this.branches = [];
16603
16618
  this.elseTemplates = [];
16604
16619
  let p = [];
@@ -16636,12 +16651,12 @@ function bind2(liquidSwell) {
16636
16651
  }
16637
16652
  *render(ctx, emitter) {
16638
16653
  const r = this.liquid.renderer;
16639
- const target = (0, import_liquidjs6.toValue)(yield this.value.value(ctx, ctx.opts.lenientIf));
16654
+ const target = (0, import_liquidjs7.toValue)(yield this.value.value(ctx, ctx.opts.lenientIf));
16640
16655
  let branchHit = false;
16641
16656
  let output = "";
16642
16657
  for (const branch of this.branches) {
16643
16658
  for (const valueToken of branch.values) {
16644
- const value = yield (0, import_liquidjs6.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
16659
+ const value = yield (0, import_liquidjs7.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
16645
16660
  if (target === value) {
16646
16661
  const blockOutput = yield r.renderTemplates(branch.templates, ctx);
16647
16662
  output += this.isBlock && liquidSwell.isEditor ? `<span class="swell-block">${blockOutput}</span>` : blockOutput;
@@ -16674,15 +16689,15 @@ function bind2(liquidSwell) {
16674
16689
  }
16675
16690
 
16676
16691
  // src/liquid/tags/comment.ts
16677
- var import_liquidjs7 = require("liquidjs");
16692
+ var import_liquidjs8 = require("liquidjs");
16678
16693
  function bind3(_liquidSwell) {
16679
- return class CommentTag extends import_liquidjs7.Tag {
16694
+ return class CommentTag extends import_liquidjs8.Tag {
16680
16695
  constructor(tagToken, remainTokens, liquid) {
16681
16696
  super(tagToken, remainTokens, liquid);
16682
16697
  let nested = 1;
16683
16698
  while (remainTokens.length > 0) {
16684
16699
  const token = remainTokens.shift();
16685
- if (import_liquidjs7.TypeGuards.isTagToken(token)) {
16700
+ if (import_liquidjs8.TypeGuards.isTagToken(token)) {
16686
16701
  switch (token.name) {
16687
16702
  case "comment":
16688
16703
  nested += 1;
@@ -16707,13 +16722,13 @@ function bind3(_liquidSwell) {
16707
16722
  }
16708
16723
 
16709
16724
  // src/liquid/tags/for.ts
16710
- var import_liquidjs8 = require("liquidjs");
16725
+ var import_liquidjs9 = require("liquidjs");
16711
16726
  var MODIFIERS = Object.freeze(["offset", "limit", "reversed"]);
16712
16727
  function bind4(_liquidSwell) {
16713
- return class ForTag extends import_liquidjs8.ForTag {
16728
+ return class ForTag extends import_liquidjs9.ForTag {
16714
16729
  *render(ctx, emitter) {
16715
16730
  const r = this.liquid.renderer;
16716
- let collection = yield (0, import_liquidjs8.evalToken)(this.collection, ctx);
16731
+ let collection = yield (0, import_liquidjs9.evalToken)(this.collection, ctx);
16717
16732
  collection = yield resolveEnumerable(collection);
16718
16733
  if (!collection.length) {
16719
16734
  yield r.renderTemplates(this.elseTemplates, ctx, emitter);
@@ -16768,10 +16783,10 @@ function limit(arr, count) {
16768
16783
  }
16769
16784
 
16770
16785
  // src/liquid/tags/form.ts
16771
- var import_liquidjs9 = require("liquidjs");
16786
+ var import_liquidjs10 = require("liquidjs");
16772
16787
  var IGNORED_SHOPIFY_FORMS = Object.freeze(["new_comment", "guest_login"]);
16773
16788
  function bind5(liquidSwell) {
16774
- return class FormTag extends import_liquidjs9.Tag {
16789
+ return class FormTag extends import_liquidjs10.Tag {
16775
16790
  formType;
16776
16791
  formConfig;
16777
16792
  templates;
@@ -16785,10 +16800,10 @@ function bind5(liquidSwell) {
16785
16800
  tokenizer.advance();
16786
16801
  this.arg = tokenizer.readValue();
16787
16802
  this.templates = [];
16788
- this.hash = new import_liquidjs9.Hash(this.tokenizer.remaining());
16803
+ this.hash = new import_liquidjs10.Hash(this.tokenizer.remaining());
16789
16804
  while (remainTokens.length > 0) {
16790
16805
  const token2 = remainTokens.shift();
16791
- if (import_liquidjs9.TypeGuards.isTagToken(token2) && token2.name === "endform") {
16806
+ if (import_liquidjs10.TypeGuards.isTagToken(token2) && token2.name === "endform") {
16792
16807
  return;
16793
16808
  }
16794
16809
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -16806,7 +16821,7 @@ function bind5(liquidSwell) {
16806
16821
  return;
16807
16822
  }
16808
16823
  const r = this.liquid.renderer;
16809
- const arg = yield (0, import_liquidjs9.evalToken)(this.arg, ctx);
16824
+ const arg = yield (0, import_liquidjs10.evalToken)(this.arg, ctx);
16810
16825
  const hash = yield this.hash.render(ctx);
16811
16826
  const scope = ctx.getAll();
16812
16827
  const attrs = " " + Object.entries(hash).reduce((acc, [key, value]) => {
@@ -16866,9 +16881,9 @@ function bind5(liquidSwell) {
16866
16881
  }
16867
16882
 
16868
16883
  // src/liquid/tags/if.ts
16869
- var import_liquidjs10 = require("liquidjs");
16884
+ var import_liquidjs11 = require("liquidjs");
16870
16885
  function bind6(_liquidSwell) {
16871
- return class IfTag extends import_liquidjs10.Tag {
16886
+ return class IfTag extends import_liquidjs11.Tag {
16872
16887
  branches = [];
16873
16888
  elseTemplates;
16874
16889
  constructor(tagToken, remainTokens, liquid, parser) {
@@ -16877,22 +16892,22 @@ function bind6(_liquidSwell) {
16877
16892
  parser.parseStream(remainTokens).on(
16878
16893
  "start",
16879
16894
  () => this.branches.push({
16880
- value: new import_liquidjs10.Value(
16895
+ value: new import_liquidjs11.Value(
16881
16896
  tagToken.tokenizer.readFilteredValue(),
16882
16897
  this.liquid
16883
16898
  ),
16884
16899
  templates: p = []
16885
16900
  })
16886
16901
  ).on("tag:elsif", (token) => {
16887
- (0, import_liquidjs10.assert)(!this.elseTemplates, "unexpected elsif after else");
16902
+ (0, import_liquidjs11.assert)(!this.elseTemplates, "unexpected elsif after else");
16888
16903
  this.branches.push({
16889
- value: new import_liquidjs10.Value(token.tokenizer.readFilteredValue(), this.liquid),
16904
+ value: new import_liquidjs11.Value(token.tokenizer.readFilteredValue(), this.liquid),
16890
16905
  templates: p = []
16891
16906
  });
16892
16907
  }).on("tag:else", (tag) => {
16893
16908
  if (tag.args.length > 0) {
16894
16909
  this.branches.push({
16895
- value: new import_liquidjs10.Value(tag.tokenizer.readFilteredValue(), this.liquid),
16910
+ value: new import_liquidjs11.Value(tag.tokenizer.readFilteredValue(), this.liquid),
16896
16911
  templates: p = []
16897
16912
  });
16898
16913
  } else {
@@ -16910,7 +16925,7 @@ function bind6(_liquidSwell) {
16910
16925
  const r = this.liquid.renderer;
16911
16926
  for (const { value, templates } of this.branches) {
16912
16927
  const v = yield value.value(ctx, ctx.opts.lenientIf);
16913
- if ((0, import_liquidjs10.isTruthy)(v, ctx)) {
16928
+ if ((0, import_liquidjs11.isTruthy)(v, ctx)) {
16914
16929
  yield r.renderTemplates(templates, ctx, emitter);
16915
16930
  return;
16916
16931
  }
@@ -16931,20 +16946,20 @@ function bind6(_liquidSwell) {
16931
16946
  };
16932
16947
  }
16933
16948
  function assertEmpty(predicate, message = `unexpected ${JSON.stringify(predicate)}`) {
16934
- (0, import_liquidjs10.assert)(!predicate, message);
16949
+ (0, import_liquidjs11.assert)(!predicate, message);
16935
16950
  }
16936
16951
 
16937
16952
  // src/liquid/tags/javascript.ts
16938
- var import_liquidjs11 = require("liquidjs");
16953
+ var import_liquidjs12 = require("liquidjs");
16939
16954
  function bind7(_liquidSwell) {
16940
- return class JavascriptTag extends import_liquidjs11.Tag {
16955
+ return class JavascriptTag extends import_liquidjs12.Tag {
16941
16956
  templates;
16942
16957
  constructor(token, remainTokens, liquid, parser) {
16943
16958
  super(token, remainTokens, liquid);
16944
16959
  this.templates = [];
16945
16960
  while (remainTokens.length > 0) {
16946
16961
  const token2 = remainTokens.shift();
16947
- if (import_liquidjs11.TypeGuards.isTagToken(token2) && token2.name === "endjavascript") {
16962
+ if (import_liquidjs12.TypeGuards.isTagToken(token2) && token2.name === "endjavascript") {
16948
16963
  return;
16949
16964
  }
16950
16965
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -16962,9 +16977,9 @@ function bind7(_liquidSwell) {
16962
16977
  }
16963
16978
 
16964
16979
  // src/liquid/tags/layout.ts
16965
- var import_liquidjs12 = require("liquidjs");
16980
+ var import_liquidjs13 = require("liquidjs");
16966
16981
  function bind8(liquidSwell) {
16967
- return class LayoutTag extends import_liquidjs12.Tag {
16982
+ return class LayoutTag extends import_liquidjs13.Tag {
16968
16983
  fileName;
16969
16984
  constructor(token, remainTokens, liquid, _parser) {
16970
16985
  super(token, remainTokens, liquid);
@@ -16980,9 +16995,9 @@ function bind8(liquidSwell) {
16980
16995
  }
16981
16996
 
16982
16997
  // src/liquid/tags/paginate.ts
16983
- var import_liquidjs13 = require("liquidjs");
16998
+ var import_liquidjs14 = require("liquidjs");
16984
16999
  function bind9(liquidSwell) {
16985
- return class PaginateTag extends import_liquidjs13.Tag {
17000
+ return class PaginateTag extends import_liquidjs14.Tag {
16986
17001
  collection;
16987
17002
  pageSize;
16988
17003
  templates;
@@ -16997,7 +17012,7 @@ function bind9(liquidSwell) {
16997
17012
  }
16998
17013
  this.templates = [];
16999
17014
  this.collection = collection;
17000
- this.hash = new import_liquidjs13.Hash(this.tokenizer.remaining());
17015
+ this.hash = new import_liquidjs14.Hash(this.tokenizer.remaining());
17001
17016
  const stream = parser.parseStream(remainTokens).on("tag:endpaginate", () => stream.stop()).on("template", (tpl) => {
17002
17017
  this.templates.push(tpl);
17003
17018
  }).on("end", () => {
@@ -17007,8 +17022,8 @@ function bind9(liquidSwell) {
17007
17022
  }
17008
17023
  *render(ctx, emitter) {
17009
17024
  const r = this.liquid.renderer;
17010
- const collection = yield (0, import_liquidjs13.evalToken)(this.collection, ctx);
17011
- const pageSize = Number(yield (0, import_liquidjs13.evalToken)(this.pageSize, ctx));
17025
+ const collection = yield (0, import_liquidjs14.evalToken)(this.collection, ctx);
17026
+ const pageSize = Number(yield (0, import_liquidjs14.evalToken)(this.pageSize, ctx));
17012
17027
  const hash = yield this.hash.render(ctx);
17013
17028
  if (!Number.isNaN(pageSize) && collection instanceof SwellStorefrontCollection && collection.limit != pageSize) {
17014
17029
  yield collection._get({
@@ -17032,9 +17047,9 @@ function bind9(liquidSwell) {
17032
17047
 
17033
17048
  // src/liquid/tags/render.ts
17034
17049
  var import_lodash_es8 = require("lodash-es");
17035
- var import_liquidjs14 = require("liquidjs");
17050
+ var import_liquidjs15 = require("liquidjs");
17036
17051
  function bind10(liquidSwell) {
17037
- return class RenderTag extends import_liquidjs14.RenderTag {
17052
+ return class RenderTag extends import_liquidjs15.RenderTag {
17038
17053
  *render(ctx, emitter) {
17039
17054
  const { liquid, hash } = this;
17040
17055
  const filepath = yield renderFilePath(
@@ -17042,7 +17057,7 @@ function bind10(liquidSwell) {
17042
17057
  ctx,
17043
17058
  liquid
17044
17059
  );
17045
- (0, import_liquidjs14.assert)(filepath, () => `illegal file path "${filepath}"`);
17060
+ (0, import_liquidjs15.assert)(filepath, () => `illegal file path "${filepath}"`);
17046
17061
  const themeConfig = yield liquidSwell.getComponentPath(filepath).then(
17047
17062
  (fileName) => liquidSwell.getThemeConfig(fileName)
17048
17063
  );
@@ -17054,11 +17069,11 @@ function bind10(liquidSwell) {
17054
17069
  if (this["with"]) {
17055
17070
  const { value, alias } = this["with"];
17056
17071
  const aliasName = alias || filepath;
17057
- scope[aliasName] = yield (0, import_liquidjs14.evalToken)(value, ctx);
17072
+ scope[aliasName] = yield (0, import_liquidjs15.evalToken)(value, ctx);
17058
17073
  }
17059
17074
  if (this["for"]) {
17060
17075
  const { value, alias } = this["for"];
17061
- let collection = yield (0, import_liquidjs14.evalToken)(value, ctx);
17076
+ let collection = yield (0, import_liquidjs15.evalToken)(value, ctx);
17062
17077
  collection = yield resolveEnumerable(collection);
17063
17078
  scope["forloop"] = new ForloopDrop(
17064
17079
  collection.length,
@@ -17091,13 +17106,13 @@ function* renderFilePath(file, ctx, liquid) {
17091
17106
  default:
17092
17107
  break;
17093
17108
  }
17094
- return yield (0, import_liquidjs14.evalToken)(file, ctx);
17109
+ return yield (0, import_liquidjs15.evalToken)(file, ctx);
17095
17110
  }
17096
17111
 
17097
17112
  // src/liquid/tags/section.ts
17098
- var import_liquidjs15 = require("liquidjs");
17113
+ var import_liquidjs16 = require("liquidjs");
17099
17114
  function bind11(liquidSwell) {
17100
- return class SectionTag extends import_liquidjs15.Tag {
17115
+ return class SectionTag extends import_liquidjs16.Tag {
17101
17116
  fileName;
17102
17117
  constructor(token, remainTokens, liquid, _parser) {
17103
17118
  super(token, remainTokens, liquid);
@@ -17133,7 +17148,7 @@ function bind11(liquidSwell) {
17133
17148
  }
17134
17149
  });
17135
17150
  });
17136
- if (output) {
17151
+ if (output && schema && settings) {
17137
17152
  const { shopify_compatibility: shopifyCompatibility } = liquidSwell.theme.globals;
17138
17153
  const tag = schema.tag || "div";
17139
17154
  const id = `${shopifyCompatibility ? "shopify" : "swell"}-section-${settings.id || this.fileName}`;
@@ -17147,10 +17162,10 @@ function bind11(liquidSwell) {
17147
17162
  }
17148
17163
 
17149
17164
  // src/liquid/tags/sections.ts
17150
- var import_liquidjs16 = require("liquidjs");
17165
+ var import_liquidjs17 = require("liquidjs");
17151
17166
  var import_json54 = __toESM(require("json5"), 1);
17152
17167
  function bind12(liquidSwell) {
17153
- return class SectionsTag extends import_liquidjs16.Tag {
17168
+ return class SectionsTag extends import_liquidjs17.Tag {
17154
17169
  fileName;
17155
17170
  constructor(token, remainTokens, liquid, _parser) {
17156
17171
  super(token, remainTokens, liquid);
@@ -17158,10 +17173,16 @@ function bind12(liquidSwell) {
17158
17173
  this.fileName = tokenizer.readValue()?.content;
17159
17174
  }
17160
17175
  *render(_ctx, emitter) {
17161
- const filePath = yield liquidSwell.getSectionGroupPath(this.fileName);
17162
- const themeConfig = yield liquidSwell.getThemeConfig(filePath);
17176
+ const filePath = yield liquidSwell.getSectionGroupPath(
17177
+ this.fileName
17178
+ );
17179
+ const themeConfig = yield liquidSwell.getThemeConfig(
17180
+ filePath
17181
+ );
17163
17182
  try {
17164
- const sectionGroup = import_json54.default.parse(themeConfig.file_data);
17183
+ const sectionGroup = import_json54.default.parse(
17184
+ themeConfig.file_data
17185
+ );
17165
17186
  const sectionConfigs = yield liquidSwell.renderPageSections(
17166
17187
  sectionGroup
17167
17188
  );
@@ -17174,6 +17195,7 @@ function bind12(liquidSwell) {
17174
17195
  return `<${tag} id="${id}" class="${className} ${section.class || ""}">${section.output}</${tag}>`;
17175
17196
  }).join("")}</div>`
17176
17197
  );
17198
+ yield liquidSwell.theme.addPageSection(this.fileName, true);
17177
17199
  } catch (err) {
17178
17200
  console.warn(err);
17179
17201
  }
@@ -17182,18 +17204,19 @@ function bind12(liquidSwell) {
17182
17204
  }
17183
17205
 
17184
17206
  // src/liquid/tags/style.ts
17185
- var import_liquidjs17 = require("liquidjs");
17207
+ var import_liquidjs18 = require("liquidjs");
17186
17208
  function bind13(_liquidSwell) {
17187
- return class StyleTag extends import_liquidjs17.Tag {
17209
+ return class StyleTag extends import_liquidjs18.Tag {
17188
17210
  templates;
17189
17211
  hash;
17190
17212
  constructor(token, remainTokens, liquid, parser) {
17191
17213
  super(token, remainTokens, liquid);
17192
- this.hash = md5(token.input);
17193
17214
  this.templates = [];
17215
+ const tagBegin = token.begin;
17194
17216
  while (remainTokens.length > 0) {
17195
17217
  const token2 = remainTokens.shift();
17196
- if (import_liquidjs17.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
17218
+ if (import_liquidjs18.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
17219
+ this.hash = md5(token2.input.slice(tagBegin, token2.end));
17197
17220
  return;
17198
17221
  }
17199
17222
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -17215,16 +17238,16 @@ function bind13(_liquidSwell) {
17215
17238
  }
17216
17239
 
17217
17240
  // src/liquid/tags/stylesheet.ts
17218
- var import_liquidjs18 = require("liquidjs");
17241
+ var import_liquidjs19 = require("liquidjs");
17219
17242
  function bind14(_liquidSwell) {
17220
- return class StyleSheetTag extends import_liquidjs18.Tag {
17243
+ return class StyleSheetTag extends import_liquidjs19.Tag {
17221
17244
  templates;
17222
17245
  constructor(token, remainTokens, liquid, parser) {
17223
17246
  super(token, remainTokens, liquid);
17224
17247
  this.templates = [];
17225
17248
  while (remainTokens.length > 0) {
17226
17249
  const token2 = remainTokens.shift();
17227
- if (import_liquidjs18.TypeGuards.isTagToken(token2) && token2.name === "endstylesheet") {
17250
+ if (import_liquidjs19.TypeGuards.isTagToken(token2) && token2.name === "endstylesheet") {
17228
17251
  return;
17229
17252
  }
17230
17253
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -17240,9 +17263,9 @@ function bind14(_liquidSwell) {
17240
17263
  }
17241
17264
 
17242
17265
  // src/liquid/tags/shopify/include.ts
17243
- var import_liquidjs19 = require("liquidjs");
17266
+ var import_liquidjs20 = require("liquidjs");
17244
17267
  function bind15(liquidSwell) {
17245
- return class IncludeTag extends import_liquidjs19.IncludeTag {
17268
+ return class IncludeTag extends import_liquidjs20.IncludeTag {
17246
17269
  *render(ctx, emitter) {
17247
17270
  const { hash } = this;
17248
17271
  const filepath = yield renderFilePath(
@@ -17250,13 +17273,13 @@ function bind15(liquidSwell) {
17250
17273
  ctx,
17251
17274
  this.liquid
17252
17275
  );
17253
- (0, import_liquidjs19.assert)(filepath, () => `illegal file path "${filepath}"`);
17276
+ (0, import_liquidjs20.assert)(filepath, () => `illegal file path "${filepath}"`);
17254
17277
  const saved = ctx.saveRegister("blocks", "blockMode");
17255
17278
  ctx.setRegister("blocks", {});
17256
17279
  ctx.setRegister("blockMode", 0);
17257
17280
  const scope = yield hash.render(ctx);
17258
17281
  if (this.withVar) {
17259
- scope[filepath] = yield (0, import_liquidjs19.evalToken)(this.withVar, ctx);
17282
+ scope[filepath] = yield (0, import_liquidjs20.evalToken)(this.withVar, ctx);
17260
17283
  }
17261
17284
  ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
17262
17285
  const output = yield liquidSwell.getComponentPath(filepath).then((path) => liquidSwell.getThemeConfig(path)).then((themeConfig) => liquidSwell.renderTemplate(themeConfig, scope));
@@ -17268,10 +17291,10 @@ function bind15(liquidSwell) {
17268
17291
  }
17269
17292
 
17270
17293
  // src/liquid/tags/shopify/schema.ts
17271
- var import_liquidjs20 = require("liquidjs");
17294
+ var import_liquidjs21 = require("liquidjs");
17272
17295
  var import_json55 = __toESM(require("json5"), 1);
17273
17296
  function bind16(liquidSwell) {
17274
- return class SchemaTag extends import_liquidjs20.Tag {
17297
+ return class SchemaTag extends import_liquidjs21.Tag {
17275
17298
  templates;
17276
17299
  constructor(token, remainTokens, liquid, parser) {
17277
17300
  super(token, remainTokens, liquid);
@@ -17304,9 +17327,9 @@ function bind16(liquidSwell) {
17304
17327
  }
17305
17328
 
17306
17329
  // src/liquid/tags/inline_editable.ts
17307
- var import_liquidjs21 = require("liquidjs");
17330
+ var import_liquidjs22 = require("liquidjs");
17308
17331
  function bind17(_liquidSwell) {
17309
- return class InlineEditableTag extends import_liquidjs21.Tag {
17332
+ return class InlineEditableTag extends import_liquidjs22.Tag {
17310
17333
  key;
17311
17334
  value;
17312
17335
  constructor(token, remainTokens, liquid, _parser) {
@@ -18303,9 +18326,9 @@ async function resolveAsyncProps(propArg, resolveProps) {
18303
18326
  }
18304
18327
 
18305
18328
  // src/liquid/operators.ts
18306
- var import_liquidjs22 = require("liquidjs");
18329
+ var import_liquidjs23 = require("liquidjs");
18307
18330
  var swellOperators = {
18308
- ...import_liquidjs22.defaultOperators,
18331
+ ...import_liquidjs23.defaultOperators,
18309
18332
  "==": equal,
18310
18333
  "!=": (l, r) => !equal(l, r),
18311
18334
  contains: (l, r) => {
@@ -18332,8 +18355,8 @@ function arrayEqual(lhs, rhs) {
18332
18355
 
18333
18356
  // src/liquid/color.ts
18334
18357
  var import_color = __toESM(require("color"), 1);
18335
- var import_liquidjs23 = require("liquidjs");
18336
- var ThemeColor = class _ThemeColor extends import_liquidjs23.Drop {
18358
+ var import_liquidjs24 = require("liquidjs");
18359
+ var ThemeColor = class _ThemeColor extends import_liquidjs24.Drop {
18337
18360
  color;
18338
18361
  colorValues;
18339
18362
  red;
@@ -18468,7 +18491,7 @@ function isThemeColorLike(value) {
18468
18491
  }
18469
18492
 
18470
18493
  // src/liquid/index.ts
18471
- var LiquidSwell30 = class extends import_liquidjs24.Liquid {
18494
+ var LiquidSwell30 = class extends import_liquidjs25.Liquid {
18472
18495
  theme;
18473
18496
  getThemeConfig;
18474
18497
  getThemeTemplateConfigByType;
@@ -18900,6 +18923,7 @@ var SwellTheme3 = class {
18900
18923
  globalData = {};
18901
18924
  // Swell-native theme settings if not using Shopify compatibility
18902
18925
  themeSettingFilePath = "theme/config/theme.json";
18926
+ pageSectionGroups = null;
18903
18927
  constructor(swell, options = {}) {
18904
18928
  const { forms, resources, globals, shopifyCompatibilityClass } = options;
18905
18929
  this.swell = swell;
@@ -19791,9 +19815,10 @@ var SwellTheme3 = class {
19791
19815
  }
19792
19816
  return "";
19793
19817
  }
19794
- async renderLayout(data) {
19795
- if (this.liquidSwell.layoutName) {
19796
- return this.renderLayoutTemplate(this.liquidSwell.layoutName, data);
19818
+ async renderLayout(layoutName, data) {
19819
+ layoutName = layoutName || this.liquidSwell.layoutName;
19820
+ if (layoutName) {
19821
+ return this.renderLayoutTemplate(layoutName, data);
19797
19822
  } else {
19798
19823
  return data?.content_for_layout || "";
19799
19824
  }
@@ -19926,15 +19951,30 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
19926
19951
  }
19927
19952
  return sectionConfigs;
19928
19953
  }
19954
+ async addPageSection(sectionFileName, group) {
19955
+ if (this.pageSectionGroups === null) {
19956
+ return;
19957
+ }
19958
+ const { pageSectionGroups } = this;
19959
+ const sectionSchema = await this.getSectionSchema(sectionFileName);
19960
+ const sectionName = sectionSchema?.label || sectionFileName;
19961
+ let sourcePath = "";
19962
+ if (group) {
19963
+ const sectionConfig = await this.getThemeTemplateConfigByType(
19964
+ "sections",
19965
+ `${sectionFileName}.json`
19966
+ );
19967
+ sourcePath = sectionConfig?.file_path ?? "";
19968
+ }
19969
+ pageSectionGroups.push({
19970
+ prop: getSectionGroupProp(sectionFileName),
19971
+ label: sectionName,
19972
+ source: sourcePath,
19973
+ group
19974
+ });
19975
+ }
19929
19976
  /**
19930
19977
  * Get a list of sections and section groups in a page layout.
19931
- *
19932
- * Basically we should get these section groups: `header`, `content` and `footer`.
19933
- * For now, section groups are searched for using regex in the page layout.
19934
- * There may be cases where section groups can be nested in other files,
19935
- * in which case they will not be visible to this function.
19936
- *
19937
- * In the future, we may use a dummy page renderer and thus extract all section groups.
19938
19978
  */
19939
19979
  async getPageSectionGroups(pageId) {
19940
19980
  const pageConfig = await this.getThemeTemplateConfigByType(
@@ -19945,45 +19985,31 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
19945
19985
  return [];
19946
19986
  }
19947
19987
  const pageSchema = parseJsonConfig(pageConfig);
19948
- const pageLayout = pageSchema.layout || "theme";
19949
- const layoutConfig = await this.getThemeTemplateConfigByType(
19950
- "layouts",
19951
- `${pageLayout}.liquid`
19952
- );
19953
- if (layoutConfig === null) {
19954
- return [];
19955
- }
19956
- const layoutData = layoutConfig.file_data;
19957
- const iterator = layoutData.matchAll(
19958
- /\bsections '(\w.*?)'|(\bcontent_for_layout\b)/gm
19959
- );
19960
- const sections = [];
19961
- for (const match of iterator) {
19962
- if (match[1]) {
19963
- const sectionFileName = match[1] || match[2];
19964
- const sectionSchema = await this.getSectionSchema(sectionFileName);
19965
- const sectionName = sectionSchema?.label || sectionFileName;
19966
- const sectionConfig = await this.getThemeTemplateConfigByType(
19967
- "sections",
19968
- `${sectionFileName}.json`
19969
- );
19970
- sections.push({
19971
- prop: getSectionGroupProp(sectionFileName),
19972
- label: sectionName,
19973
- source: sectionConfig?.file_path
19974
- });
19975
- } else if (match[2]) {
19976
- sections.push({
19988
+ const pageLayout = pageSchema.layout || "";
19989
+ const pageSectionGroups = [];
19990
+ this.pageSectionGroups = pageSectionGroups;
19991
+ await this.renderLayout(pageLayout, {
19992
+ content_for_layout: new RenderDrop(() => {
19993
+ pageSectionGroups.push({
19977
19994
  prop: SECTION_GROUP_CONTENT,
19978
19995
  label: "Template",
19979
- source: pageConfig.file_path
19996
+ source: pageConfig.file_path,
19997
+ group: true
19980
19998
  });
19999
+ return "";
20000
+ })
20001
+ });
20002
+ this.pageSectionGroups = null;
20003
+ return pageSectionGroups;
20004
+ }
20005
+ async getLayoutSectionGroups(sectionGroups, resolveSettings = true) {
20006
+ const configs = /* @__PURE__ */ new Map();
20007
+ for (const sectionGroup of sectionGroups) {
20008
+ const config = await this.getThemeConfig(sectionGroup.source);
20009
+ if (config) {
20010
+ configs.set(config.file_path, config);
19981
20011
  }
19982
20012
  }
19983
- return sections;
19984
- }
19985
- async getLayoutSectionGroups(resolveSettings = true) {
19986
- const configs = await this.getThemeConfigsByPath("theme/sections/");
19987
20013
  const layoutSectionGroups = await getLayoutSectionGroups(
19988
20014
  configs,
19989
20015
  this.getTemplateSchema.bind(this)