@swell/apps-sdk 1.0.123 → 1.0.125

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8057,7 +8057,7 @@ ${formattedMessage}`;
8057
8057
  {
8058
8058
  _id: "swell_page",
8059
8059
  _component: "swell_page",
8060
- ContentSections: pageSections.filter((config) => componentSet.has(config.section.type)).map(({ section, settings, schema }) => ({
8060
+ [SECTION_GROUP_CONTENT]: pageSections.filter((config) => componentSet.has(config.section.type)).map(({ section, settings, schema }) => ({
8061
8061
  _id: prepareSectionId(section.id),
8062
8062
  _component: section.type,
8063
8063
  custom_css: settings?.section?.custom_css || "",
@@ -16436,13 +16436,25 @@ ${injects.join("\n")}<\/script>`;
16436
16436
  );
16437
16437
  }
16438
16438
 
16439
+ // src/compatibility/drops/render.ts
16440
+ var import_liquidjs5 = __require("liquidjs");
16441
+ var RenderDrop = class extends import_liquidjs5.Drop {
16442
+ constructor(handler) {
16443
+ super();
16444
+ this.handler = handler;
16445
+ }
16446
+ valueOf() {
16447
+ return this.handler();
16448
+ }
16449
+ };
16450
+
16439
16451
  // src/liquid/index.ts
16440
- var import_liquidjs24 = __require("liquidjs");
16452
+ var import_liquidjs25 = __require("liquidjs");
16441
16453
 
16442
16454
  // src/liquid/tags/assign.ts
16443
- var import_liquidjs5 = __require("liquidjs");
16455
+ var import_liquidjs6 = __require("liquidjs");
16444
16456
  function bind(_liquidSwell) {
16445
- return class AssignTag extends import_liquidjs5.Tag {
16457
+ return class AssignTag extends import_liquidjs6.Tag {
16446
16458
  key;
16447
16459
  value;
16448
16460
  identifier;
@@ -16454,7 +16466,7 @@ ${injects.join("\n")}<\/script>`;
16454
16466
  this.tokenizer.skipBlank();
16455
16467
  this.tokenizer.advance();
16456
16468
  try {
16457
- this.value = new import_liquidjs5.Value(this.tokenizer.readFilteredValue(), this.liquid);
16469
+ this.value = new import_liquidjs6.Value(this.tokenizer.readFilteredValue(), this.liquid);
16458
16470
  } catch (e) {
16459
16471
  console.warn(
16460
16472
  `Liquid "assign" tag: ${e instanceof Error ? e.stack : String(e)}`
@@ -16481,9 +16493,9 @@ ${injects.join("\n")}<\/script>`;
16481
16493
  }
16482
16494
 
16483
16495
  // src/liquid/tags/case.ts
16484
- var import_liquidjs6 = __require("liquidjs");
16496
+ var import_liquidjs7 = __require("liquidjs");
16485
16497
  function bind2(liquidSwell) {
16486
- return class CaseTag extends import_liquidjs6.Tag {
16498
+ return class CaseTag extends import_liquidjs7.Tag {
16487
16499
  value;
16488
16500
  branches;
16489
16501
  elseTemplates;
@@ -16494,7 +16506,7 @@ ${injects.join("\n")}<\/script>`;
16494
16506
  const caseVar = this.tokenizer.readValue()?.getText();
16495
16507
  this.isBlock = Boolean(caseVar?.startsWith("block."));
16496
16508
  this.tokenizer.p = begin;
16497
- this.value = new import_liquidjs6.Value(this.tokenizer.readFilteredValue(), this.liquid);
16509
+ this.value = new import_liquidjs7.Value(this.tokenizer.readFilteredValue(), this.liquid);
16498
16510
  this.branches = [];
16499
16511
  this.elseTemplates = [];
16500
16512
  let p = [];
@@ -16532,12 +16544,12 @@ ${injects.join("\n")}<\/script>`;
16532
16544
  }
16533
16545
  *render(ctx, emitter) {
16534
16546
  const r = this.liquid.renderer;
16535
- const target = (0, import_liquidjs6.toValue)(yield this.value.value(ctx, ctx.opts.lenientIf));
16547
+ const target = (0, import_liquidjs7.toValue)(yield this.value.value(ctx, ctx.opts.lenientIf));
16536
16548
  let branchHit = false;
16537
16549
  let output = "";
16538
16550
  for (const branch of this.branches) {
16539
16551
  for (const valueToken of branch.values) {
16540
- const value = yield (0, import_liquidjs6.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
16552
+ const value = yield (0, import_liquidjs7.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
16541
16553
  if (target === value) {
16542
16554
  const blockOutput = yield r.renderTemplates(branch.templates, ctx);
16543
16555
  output += this.isBlock && liquidSwell.isEditor ? `<span class="swell-block">${blockOutput}</span>` : blockOutput;
@@ -16570,15 +16582,15 @@ ${injects.join("\n")}<\/script>`;
16570
16582
  }
16571
16583
 
16572
16584
  // src/liquid/tags/comment.ts
16573
- var import_liquidjs7 = __require("liquidjs");
16585
+ var import_liquidjs8 = __require("liquidjs");
16574
16586
  function bind3(_liquidSwell) {
16575
- return class CommentTag extends import_liquidjs7.Tag {
16587
+ return class CommentTag extends import_liquidjs8.Tag {
16576
16588
  constructor(tagToken, remainTokens, liquid) {
16577
16589
  super(tagToken, remainTokens, liquid);
16578
16590
  let nested = 1;
16579
16591
  while (remainTokens.length > 0) {
16580
16592
  const token = remainTokens.shift();
16581
- if (import_liquidjs7.TypeGuards.isTagToken(token)) {
16593
+ if (import_liquidjs8.TypeGuards.isTagToken(token)) {
16582
16594
  switch (token.name) {
16583
16595
  case "comment":
16584
16596
  nested += 1;
@@ -16603,13 +16615,13 @@ ${injects.join("\n")}<\/script>`;
16603
16615
  }
16604
16616
 
16605
16617
  // src/liquid/tags/for.ts
16606
- var import_liquidjs8 = __require("liquidjs");
16618
+ var import_liquidjs9 = __require("liquidjs");
16607
16619
  var MODIFIERS = Object.freeze(["offset", "limit", "reversed"]);
16608
16620
  function bind4(_liquidSwell) {
16609
- return class ForTag extends import_liquidjs8.ForTag {
16621
+ return class ForTag extends import_liquidjs9.ForTag {
16610
16622
  *render(ctx, emitter) {
16611
16623
  const r = this.liquid.renderer;
16612
- let collection = yield (0, import_liquidjs8.evalToken)(this.collection, ctx);
16624
+ let collection = yield (0, import_liquidjs9.evalToken)(this.collection, ctx);
16613
16625
  collection = yield resolveEnumerable(collection);
16614
16626
  if (!collection.length) {
16615
16627
  yield r.renderTemplates(this.elseTemplates, ctx, emitter);
@@ -16664,10 +16676,10 @@ ${injects.join("\n")}<\/script>`;
16664
16676
  }
16665
16677
 
16666
16678
  // src/liquid/tags/form.ts
16667
- var import_liquidjs9 = __require("liquidjs");
16679
+ var import_liquidjs10 = __require("liquidjs");
16668
16680
  var IGNORED_SHOPIFY_FORMS = Object.freeze(["new_comment", "guest_login"]);
16669
16681
  function bind5(liquidSwell) {
16670
- return class FormTag extends import_liquidjs9.Tag {
16682
+ return class FormTag extends import_liquidjs10.Tag {
16671
16683
  formType;
16672
16684
  formConfig;
16673
16685
  templates;
@@ -16681,10 +16693,10 @@ ${injects.join("\n")}<\/script>`;
16681
16693
  tokenizer.advance();
16682
16694
  this.arg = tokenizer.readValue();
16683
16695
  this.templates = [];
16684
- this.hash = new import_liquidjs9.Hash(this.tokenizer.remaining());
16696
+ this.hash = new import_liquidjs10.Hash(this.tokenizer.remaining());
16685
16697
  while (remainTokens.length > 0) {
16686
16698
  const token2 = remainTokens.shift();
16687
- if (import_liquidjs9.TypeGuards.isTagToken(token2) && token2.name === "endform") {
16699
+ if (import_liquidjs10.TypeGuards.isTagToken(token2) && token2.name === "endform") {
16688
16700
  return;
16689
16701
  }
16690
16702
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -16702,7 +16714,7 @@ ${injects.join("\n")}<\/script>`;
16702
16714
  return;
16703
16715
  }
16704
16716
  const r = this.liquid.renderer;
16705
- const arg = yield (0, import_liquidjs9.evalToken)(this.arg, ctx);
16717
+ const arg = yield (0, import_liquidjs10.evalToken)(this.arg, ctx);
16706
16718
  const hash = yield this.hash.render(ctx);
16707
16719
  const scope = ctx.getAll();
16708
16720
  const attrs = " " + Object.entries(hash).reduce((acc, [key, value]) => {
@@ -16762,9 +16774,9 @@ ${injects.join("\n")}<\/script>`;
16762
16774
  }
16763
16775
 
16764
16776
  // src/liquid/tags/if.ts
16765
- var import_liquidjs10 = __require("liquidjs");
16777
+ var import_liquidjs11 = __require("liquidjs");
16766
16778
  function bind6(_liquidSwell) {
16767
- return class IfTag extends import_liquidjs10.Tag {
16779
+ return class IfTag extends import_liquidjs11.Tag {
16768
16780
  branches = [];
16769
16781
  elseTemplates;
16770
16782
  constructor(tagToken, remainTokens, liquid, parser) {
@@ -16773,22 +16785,22 @@ ${injects.join("\n")}<\/script>`;
16773
16785
  parser.parseStream(remainTokens).on(
16774
16786
  "start",
16775
16787
  () => this.branches.push({
16776
- value: new import_liquidjs10.Value(
16788
+ value: new import_liquidjs11.Value(
16777
16789
  tagToken.tokenizer.readFilteredValue(),
16778
16790
  this.liquid
16779
16791
  ),
16780
16792
  templates: p = []
16781
16793
  })
16782
16794
  ).on("tag:elsif", (token) => {
16783
- (0, import_liquidjs10.assert)(!this.elseTemplates, "unexpected elsif after else");
16795
+ (0, import_liquidjs11.assert)(!this.elseTemplates, "unexpected elsif after else");
16784
16796
  this.branches.push({
16785
- value: new import_liquidjs10.Value(token.tokenizer.readFilteredValue(), this.liquid),
16797
+ value: new import_liquidjs11.Value(token.tokenizer.readFilteredValue(), this.liquid),
16786
16798
  templates: p = []
16787
16799
  });
16788
16800
  }).on("tag:else", (tag) => {
16789
16801
  if (tag.args.length > 0) {
16790
16802
  this.branches.push({
16791
- value: new import_liquidjs10.Value(tag.tokenizer.readFilteredValue(), this.liquid),
16803
+ value: new import_liquidjs11.Value(tag.tokenizer.readFilteredValue(), this.liquid),
16792
16804
  templates: p = []
16793
16805
  });
16794
16806
  } else {
@@ -16806,7 +16818,7 @@ ${injects.join("\n")}<\/script>`;
16806
16818
  const r = this.liquid.renderer;
16807
16819
  for (const { value, templates } of this.branches) {
16808
16820
  const v = yield value.value(ctx, ctx.opts.lenientIf);
16809
- if ((0, import_liquidjs10.isTruthy)(v, ctx)) {
16821
+ if ((0, import_liquidjs11.isTruthy)(v, ctx)) {
16810
16822
  yield r.renderTemplates(templates, ctx, emitter);
16811
16823
  return;
16812
16824
  }
@@ -16827,20 +16839,20 @@ ${injects.join("\n")}<\/script>`;
16827
16839
  };
16828
16840
  }
16829
16841
  function assertEmpty(predicate, message = `unexpected ${JSON.stringify(predicate)}`) {
16830
- (0, import_liquidjs10.assert)(!predicate, message);
16842
+ (0, import_liquidjs11.assert)(!predicate, message);
16831
16843
  }
16832
16844
 
16833
16845
  // src/liquid/tags/javascript.ts
16834
- var import_liquidjs11 = __require("liquidjs");
16846
+ var import_liquidjs12 = __require("liquidjs");
16835
16847
  function bind7(_liquidSwell) {
16836
- return class JavascriptTag extends import_liquidjs11.Tag {
16848
+ return class JavascriptTag extends import_liquidjs12.Tag {
16837
16849
  templates;
16838
16850
  constructor(token, remainTokens, liquid, parser) {
16839
16851
  super(token, remainTokens, liquid);
16840
16852
  this.templates = [];
16841
16853
  while (remainTokens.length > 0) {
16842
16854
  const token2 = remainTokens.shift();
16843
- if (import_liquidjs11.TypeGuards.isTagToken(token2) && token2.name === "endjavascript") {
16855
+ if (import_liquidjs12.TypeGuards.isTagToken(token2) && token2.name === "endjavascript") {
16844
16856
  return;
16845
16857
  }
16846
16858
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -16858,9 +16870,9 @@ ${injects.join("\n")}<\/script>`;
16858
16870
  }
16859
16871
 
16860
16872
  // src/liquid/tags/layout.ts
16861
- var import_liquidjs12 = __require("liquidjs");
16873
+ var import_liquidjs13 = __require("liquidjs");
16862
16874
  function bind8(liquidSwell) {
16863
- return class LayoutTag extends import_liquidjs12.Tag {
16875
+ return class LayoutTag extends import_liquidjs13.Tag {
16864
16876
  fileName;
16865
16877
  constructor(token, remainTokens, liquid, _parser) {
16866
16878
  super(token, remainTokens, liquid);
@@ -16876,9 +16888,9 @@ ${injects.join("\n")}<\/script>`;
16876
16888
  }
16877
16889
 
16878
16890
  // src/liquid/tags/paginate.ts
16879
- var import_liquidjs13 = __require("liquidjs");
16891
+ var import_liquidjs14 = __require("liquidjs");
16880
16892
  function bind9(liquidSwell) {
16881
- return class PaginateTag extends import_liquidjs13.Tag {
16893
+ return class PaginateTag extends import_liquidjs14.Tag {
16882
16894
  collection;
16883
16895
  pageSize;
16884
16896
  templates;
@@ -16893,7 +16905,7 @@ ${injects.join("\n")}<\/script>`;
16893
16905
  }
16894
16906
  this.templates = [];
16895
16907
  this.collection = collection;
16896
- this.hash = new import_liquidjs13.Hash(this.tokenizer.remaining());
16908
+ this.hash = new import_liquidjs14.Hash(this.tokenizer.remaining());
16897
16909
  const stream = parser.parseStream(remainTokens).on("tag:endpaginate", () => stream.stop()).on("template", (tpl) => {
16898
16910
  this.templates.push(tpl);
16899
16911
  }).on("end", () => {
@@ -16903,8 +16915,8 @@ ${injects.join("\n")}<\/script>`;
16903
16915
  }
16904
16916
  *render(ctx, emitter) {
16905
16917
  const r = this.liquid.renderer;
16906
- const collection = yield (0, import_liquidjs13.evalToken)(this.collection, ctx);
16907
- const pageSize = Number(yield (0, import_liquidjs13.evalToken)(this.pageSize, ctx));
16918
+ const collection = yield (0, import_liquidjs14.evalToken)(this.collection, ctx);
16919
+ const pageSize = Number(yield (0, import_liquidjs14.evalToken)(this.pageSize, ctx));
16908
16920
  const hash = yield this.hash.render(ctx);
16909
16921
  if (!Number.isNaN(pageSize) && collection instanceof SwellStorefrontCollection && collection.limit != pageSize) {
16910
16922
  yield collection._get({
@@ -16928,9 +16940,9 @@ ${injects.join("\n")}<\/script>`;
16928
16940
 
16929
16941
  // src/liquid/tags/render.ts
16930
16942
  var import_lodash_es8 = __require("lodash-es");
16931
- var import_liquidjs14 = __require("liquidjs");
16943
+ var import_liquidjs15 = __require("liquidjs");
16932
16944
  function bind10(liquidSwell) {
16933
- return class RenderTag extends import_liquidjs14.RenderTag {
16945
+ return class RenderTag extends import_liquidjs15.RenderTag {
16934
16946
  *render(ctx, emitter) {
16935
16947
  const { liquid, hash } = this;
16936
16948
  const filepath = yield renderFilePath(
@@ -16938,7 +16950,7 @@ ${injects.join("\n")}<\/script>`;
16938
16950
  ctx,
16939
16951
  liquid
16940
16952
  );
16941
- (0, import_liquidjs14.assert)(filepath, () => `illegal file path "${filepath}"`);
16953
+ (0, import_liquidjs15.assert)(filepath, () => `illegal file path "${filepath}"`);
16942
16954
  const themeConfig = yield liquidSwell.getComponentPath(filepath).then(
16943
16955
  (fileName) => liquidSwell.getThemeConfig(fileName)
16944
16956
  );
@@ -16950,11 +16962,11 @@ ${injects.join("\n")}<\/script>`;
16950
16962
  if (this["with"]) {
16951
16963
  const { value, alias } = this["with"];
16952
16964
  const aliasName = alias || filepath;
16953
- scope[aliasName] = yield (0, import_liquidjs14.evalToken)(value, ctx);
16965
+ scope[aliasName] = yield (0, import_liquidjs15.evalToken)(value, ctx);
16954
16966
  }
16955
16967
  if (this["for"]) {
16956
16968
  const { value, alias } = this["for"];
16957
- let collection = yield (0, import_liquidjs14.evalToken)(value, ctx);
16969
+ let collection = yield (0, import_liquidjs15.evalToken)(value, ctx);
16958
16970
  collection = yield resolveEnumerable(collection);
16959
16971
  scope["forloop"] = new ForloopDrop(
16960
16972
  collection.length,
@@ -16987,13 +16999,13 @@ ${injects.join("\n")}<\/script>`;
16987
16999
  default:
16988
17000
  break;
16989
17001
  }
16990
- return yield (0, import_liquidjs14.evalToken)(file, ctx);
17002
+ return yield (0, import_liquidjs15.evalToken)(file, ctx);
16991
17003
  }
16992
17004
 
16993
17005
  // src/liquid/tags/section.ts
16994
- var import_liquidjs15 = __require("liquidjs");
17006
+ var import_liquidjs16 = __require("liquidjs");
16995
17007
  function bind11(liquidSwell) {
16996
- return class SectionTag extends import_liquidjs15.Tag {
17008
+ return class SectionTag extends import_liquidjs16.Tag {
16997
17009
  fileName;
16998
17010
  constructor(token, remainTokens, liquid, _parser) {
16999
17011
  super(token, remainTokens, liquid);
@@ -17029,7 +17041,7 @@ ${injects.join("\n")}<\/script>`;
17029
17041
  }
17030
17042
  });
17031
17043
  });
17032
- if (output) {
17044
+ if (output && schema && settings) {
17033
17045
  const { shopify_compatibility: shopifyCompatibility } = liquidSwell.theme.globals;
17034
17046
  const tag = schema.tag || "div";
17035
17047
  const id = `${shopifyCompatibility ? "shopify" : "swell"}-section-${settings.id || this.fileName}`;
@@ -17043,10 +17055,10 @@ ${injects.join("\n")}<\/script>`;
17043
17055
  }
17044
17056
 
17045
17057
  // src/liquid/tags/sections.ts
17046
- var import_liquidjs16 = __require("liquidjs");
17058
+ var import_liquidjs17 = __require("liquidjs");
17047
17059
  var import_json54 = __toESM(__require("json5"), 1);
17048
17060
  function bind12(liquidSwell) {
17049
- return class SectionsTag extends import_liquidjs16.Tag {
17061
+ return class SectionsTag extends import_liquidjs17.Tag {
17050
17062
  fileName;
17051
17063
  constructor(token, remainTokens, liquid, _parser) {
17052
17064
  super(token, remainTokens, liquid);
@@ -17054,10 +17066,16 @@ ${injects.join("\n")}<\/script>`;
17054
17066
  this.fileName = tokenizer.readValue()?.content;
17055
17067
  }
17056
17068
  *render(_ctx, emitter) {
17057
- const filePath = yield liquidSwell.getSectionGroupPath(this.fileName);
17058
- const themeConfig = yield liquidSwell.getThemeConfig(filePath);
17069
+ const filePath = yield liquidSwell.getSectionGroupPath(
17070
+ this.fileName
17071
+ );
17072
+ const themeConfig = yield liquidSwell.getThemeConfig(
17073
+ filePath
17074
+ );
17059
17075
  try {
17060
- const sectionGroup = import_json54.default.parse(themeConfig.file_data);
17076
+ const sectionGroup = import_json54.default.parse(
17077
+ themeConfig.file_data
17078
+ );
17061
17079
  const sectionConfigs = yield liquidSwell.renderPageSections(
17062
17080
  sectionGroup
17063
17081
  );
@@ -17070,6 +17088,7 @@ ${injects.join("\n")}<\/script>`;
17070
17088
  return `<${tag} id="${id}" class="${className} ${section.class || ""}">${section.output}</${tag}>`;
17071
17089
  }).join("")}</div>`
17072
17090
  );
17091
+ yield liquidSwell.theme.addPageSection(this.fileName, true);
17073
17092
  } catch (err) {
17074
17093
  console.warn(err);
17075
17094
  }
@@ -17078,9 +17097,9 @@ ${injects.join("\n")}<\/script>`;
17078
17097
  }
17079
17098
 
17080
17099
  // src/liquid/tags/style.ts
17081
- var import_liquidjs17 = __require("liquidjs");
17100
+ var import_liquidjs18 = __require("liquidjs");
17082
17101
  function bind13(_liquidSwell) {
17083
- return class StyleTag extends import_liquidjs17.Tag {
17102
+ return class StyleTag extends import_liquidjs18.Tag {
17084
17103
  templates;
17085
17104
  hash;
17086
17105
  constructor(token, remainTokens, liquid, parser) {
@@ -17089,7 +17108,7 @@ ${injects.join("\n")}<\/script>`;
17089
17108
  this.templates = [];
17090
17109
  while (remainTokens.length > 0) {
17091
17110
  const token2 = remainTokens.shift();
17092
- if (import_liquidjs17.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
17111
+ if (import_liquidjs18.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
17093
17112
  return;
17094
17113
  }
17095
17114
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -17111,16 +17130,16 @@ ${injects.join("\n")}<\/script>`;
17111
17130
  }
17112
17131
 
17113
17132
  // src/liquid/tags/stylesheet.ts
17114
- var import_liquidjs18 = __require("liquidjs");
17133
+ var import_liquidjs19 = __require("liquidjs");
17115
17134
  function bind14(_liquidSwell) {
17116
- return class StyleSheetTag extends import_liquidjs18.Tag {
17135
+ return class StyleSheetTag extends import_liquidjs19.Tag {
17117
17136
  templates;
17118
17137
  constructor(token, remainTokens, liquid, parser) {
17119
17138
  super(token, remainTokens, liquid);
17120
17139
  this.templates = [];
17121
17140
  while (remainTokens.length > 0) {
17122
17141
  const token2 = remainTokens.shift();
17123
- if (import_liquidjs18.TypeGuards.isTagToken(token2) && token2.name === "endstylesheet") {
17142
+ if (import_liquidjs19.TypeGuards.isTagToken(token2) && token2.name === "endstylesheet") {
17124
17143
  return;
17125
17144
  }
17126
17145
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -17136,9 +17155,9 @@ ${injects.join("\n")}<\/script>`;
17136
17155
  }
17137
17156
 
17138
17157
  // src/liquid/tags/shopify/include.ts
17139
- var import_liquidjs19 = __require("liquidjs");
17158
+ var import_liquidjs20 = __require("liquidjs");
17140
17159
  function bind15(liquidSwell) {
17141
- return class IncludeTag extends import_liquidjs19.IncludeTag {
17160
+ return class IncludeTag extends import_liquidjs20.IncludeTag {
17142
17161
  *render(ctx, emitter) {
17143
17162
  const { hash } = this;
17144
17163
  const filepath = yield renderFilePath(
@@ -17146,13 +17165,13 @@ ${injects.join("\n")}<\/script>`;
17146
17165
  ctx,
17147
17166
  this.liquid
17148
17167
  );
17149
- (0, import_liquidjs19.assert)(filepath, () => `illegal file path "${filepath}"`);
17168
+ (0, import_liquidjs20.assert)(filepath, () => `illegal file path "${filepath}"`);
17150
17169
  const saved = ctx.saveRegister("blocks", "blockMode");
17151
17170
  ctx.setRegister("blocks", {});
17152
17171
  ctx.setRegister("blockMode", 0);
17153
17172
  const scope = yield hash.render(ctx);
17154
17173
  if (this.withVar) {
17155
- scope[filepath] = yield (0, import_liquidjs19.evalToken)(this.withVar, ctx);
17174
+ scope[filepath] = yield (0, import_liquidjs20.evalToken)(this.withVar, ctx);
17156
17175
  }
17157
17176
  ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
17158
17177
  const output = yield liquidSwell.getComponentPath(filepath).then((path) => liquidSwell.getThemeConfig(path)).then((themeConfig) => liquidSwell.renderTemplate(themeConfig, scope));
@@ -17164,10 +17183,10 @@ ${injects.join("\n")}<\/script>`;
17164
17183
  }
17165
17184
 
17166
17185
  // src/liquid/tags/shopify/schema.ts
17167
- var import_liquidjs20 = __require("liquidjs");
17186
+ var import_liquidjs21 = __require("liquidjs");
17168
17187
  var import_json55 = __toESM(__require("json5"), 1);
17169
17188
  function bind16(liquidSwell) {
17170
- return class SchemaTag extends import_liquidjs20.Tag {
17189
+ return class SchemaTag extends import_liquidjs21.Tag {
17171
17190
  templates;
17172
17191
  constructor(token, remainTokens, liquid, parser) {
17173
17192
  super(token, remainTokens, liquid);
@@ -17200,9 +17219,9 @@ ${injects.join("\n")}<\/script>`;
17200
17219
  }
17201
17220
 
17202
17221
  // src/liquid/tags/inline_editable.ts
17203
- var import_liquidjs21 = __require("liquidjs");
17222
+ var import_liquidjs22 = __require("liquidjs");
17204
17223
  function bind17(_liquidSwell) {
17205
- return class InlineEditableTag extends import_liquidjs21.Tag {
17224
+ return class InlineEditableTag extends import_liquidjs22.Tag {
17206
17225
  key;
17207
17226
  value;
17208
17227
  constructor(token, remainTokens, liquid, _parser) {
@@ -18199,9 +18218,9 @@ ${injects.join("\n")}<\/script>`;
18199
18218
  }
18200
18219
 
18201
18220
  // src/liquid/operators.ts
18202
- var import_liquidjs22 = __require("liquidjs");
18221
+ var import_liquidjs23 = __require("liquidjs");
18203
18222
  var swellOperators = {
18204
- ...import_liquidjs22.defaultOperators,
18223
+ ...import_liquidjs23.defaultOperators,
18205
18224
  "==": equal,
18206
18225
  "!=": (l, r) => !equal(l, r),
18207
18226
  contains: (l, r) => {
@@ -18228,8 +18247,8 @@ ${injects.join("\n")}<\/script>`;
18228
18247
 
18229
18248
  // src/liquid/color.ts
18230
18249
  var import_color = __toESM(__require("color"), 1);
18231
- var import_liquidjs23 = __require("liquidjs");
18232
- var ThemeColor = class _ThemeColor extends import_liquidjs23.Drop {
18250
+ var import_liquidjs24 = __require("liquidjs");
18251
+ var ThemeColor = class _ThemeColor extends import_liquidjs24.Drop {
18233
18252
  color;
18234
18253
  colorValues;
18235
18254
  red;
@@ -18364,7 +18383,7 @@ ${injects.join("\n")}<\/script>`;
18364
18383
  }
18365
18384
 
18366
18385
  // src/liquid/index.ts
18367
- var LiquidSwell30 = class extends import_liquidjs24.Liquid {
18386
+ var LiquidSwell30 = class extends import_liquidjs25.Liquid {
18368
18387
  theme;
18369
18388
  getThemeConfig;
18370
18389
  getThemeTemplateConfigByType;
@@ -18796,6 +18815,7 @@ ${injects.join("\n")}<\/script>`;
18796
18815
  globalData = {};
18797
18816
  // Swell-native theme settings if not using Shopify compatibility
18798
18817
  themeSettingFilePath = "theme/config/theme.json";
18818
+ pageSectionGroups = null;
18799
18819
  constructor(swell, options = {}) {
18800
18820
  const { forms, resources, globals, shopifyCompatibilityClass } = options;
18801
18821
  this.swell = swell;
@@ -19687,9 +19707,10 @@ ${injects.join("\n")}<\/script>`;
19687
19707
  }
19688
19708
  return "";
19689
19709
  }
19690
- async renderLayout(data) {
19691
- if (this.liquidSwell.layoutName) {
19692
- return this.renderLayoutTemplate(this.liquidSwell.layoutName, data);
19710
+ async renderLayout(layoutName, data) {
19711
+ layoutName = layoutName || this.liquidSwell.layoutName;
19712
+ if (layoutName) {
19713
+ return this.renderLayoutTemplate(layoutName, data);
19693
19714
  } else {
19694
19715
  return data?.content_for_layout || "";
19695
19716
  }
@@ -19822,15 +19843,30 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
19822
19843
  }
19823
19844
  return sectionConfigs;
19824
19845
  }
19846
+ async addPageSection(sectionFileName, group) {
19847
+ if (this.pageSectionGroups === null) {
19848
+ return;
19849
+ }
19850
+ const { pageSectionGroups } = this;
19851
+ const sectionSchema = await this.getSectionSchema(sectionFileName);
19852
+ const sectionName = sectionSchema?.label || sectionFileName;
19853
+ let sourcePath = "";
19854
+ if (group) {
19855
+ const sectionConfig = await this.getThemeTemplateConfigByType(
19856
+ "sections",
19857
+ `${sectionFileName}.json`
19858
+ );
19859
+ sourcePath = sectionConfig?.file_path ?? "";
19860
+ }
19861
+ pageSectionGroups.push({
19862
+ prop: getSectionGroupProp(sectionFileName),
19863
+ label: sectionName,
19864
+ source: sourcePath,
19865
+ group
19866
+ });
19867
+ }
19825
19868
  /**
19826
19869
  * Get a list of sections and section groups in a page layout.
19827
- *
19828
- * Basically we should get these section groups: `header`, `content` and `footer`.
19829
- * For now, section groups are searched for using regex in the page layout.
19830
- * There may be cases where section groups can be nested in other files,
19831
- * in which case they will not be visible to this function.
19832
- *
19833
- * In the future, we may use a dummy page renderer and thus extract all section groups.
19834
19870
  */
19835
19871
  async getPageSectionGroups(pageId) {
19836
19872
  const pageConfig = await this.getThemeTemplateConfigByType(
@@ -19841,45 +19877,31 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
19841
19877
  return [];
19842
19878
  }
19843
19879
  const pageSchema = parseJsonConfig(pageConfig);
19844
- const pageLayout = pageSchema.layout || "theme";
19845
- const layoutConfig = await this.getThemeTemplateConfigByType(
19846
- "layouts",
19847
- `${pageLayout}.liquid`
19848
- );
19849
- if (layoutConfig === null) {
19850
- return [];
19851
- }
19852
- const layoutData = layoutConfig.file_data;
19853
- const iterator = layoutData.matchAll(
19854
- /\bsections '(\w.*?)'|(\bcontent_for_layout\b)/gm
19855
- );
19856
- const sections = [];
19857
- for (const match of iterator) {
19858
- if (match[1]) {
19859
- const sectionFileName = match[1] || match[2];
19860
- const sectionSchema = await this.getSectionSchema(sectionFileName);
19861
- const sectionName = sectionSchema?.label || sectionFileName;
19862
- const sectionConfig = await this.getThemeTemplateConfigByType(
19863
- "sections",
19864
- `${sectionFileName}.json`
19865
- );
19866
- sections.push({
19867
- prop: getSectionGroupProp(sectionFileName),
19868
- label: sectionName,
19869
- source: sectionConfig?.file_path
19870
- });
19871
- } else if (match[2]) {
19872
- sections.push({
19880
+ const pageLayout = pageSchema.layout || "";
19881
+ const pageSectionGroups = [];
19882
+ this.pageSectionGroups = pageSectionGroups;
19883
+ await this.renderLayout(pageLayout, {
19884
+ content_for_layout: new RenderDrop(() => {
19885
+ pageSectionGroups.push({
19873
19886
  prop: SECTION_GROUP_CONTENT,
19874
19887
  label: "Template",
19875
- source: pageConfig.file_path
19888
+ source: pageConfig.file_path,
19889
+ group: true
19876
19890
  });
19891
+ return "";
19892
+ })
19893
+ });
19894
+ this.pageSectionGroups = null;
19895
+ return pageSectionGroups;
19896
+ }
19897
+ async getLayoutSectionGroups(sectionGroups, resolveSettings = true) {
19898
+ const configs = /* @__PURE__ */ new Map();
19899
+ for (const sectionGroup of sectionGroups) {
19900
+ const config = await this.getThemeConfig(sectionGroup.source);
19901
+ if (config) {
19902
+ configs.set(config.file_path, config);
19877
19903
  }
19878
19904
  }
19879
- return sections;
19880
- }
19881
- async getLayoutSectionGroups(resolveSettings = true) {
19882
- const configs = await this.getThemeConfigsByPath("theme/sections/");
19883
19905
  const layoutSectionGroups = await getLayoutSectionGroups(
19884
19906
  configs,
19885
19907
  this.getTemplateSchema.bind(this)