@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.cjs +138 -116
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +138 -116
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +73 -51
- package/dist/index.mjs.map +4 -4
- package/dist/src/compatibility/drops/render.d.ts +6 -0
- package/dist/src/theme.d.ts +4 -9
- package/dist/types/swell.d.ts +1 -0
- package/package.json +1 -1
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
|
-
|
|
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 || "",
|
|
@@ -16540,13 +16540,25 @@ function ShopifyTemplate(_instance, template) {
|
|
|
16540
16540
|
);
|
|
16541
16541
|
}
|
|
16542
16542
|
|
|
16543
|
+
// src/compatibility/drops/render.ts
|
|
16544
|
+
var import_liquidjs5 = require("liquidjs");
|
|
16545
|
+
var RenderDrop = class extends import_liquidjs5.Drop {
|
|
16546
|
+
constructor(handler) {
|
|
16547
|
+
super();
|
|
16548
|
+
this.handler = handler;
|
|
16549
|
+
}
|
|
16550
|
+
valueOf() {
|
|
16551
|
+
return this.handler();
|
|
16552
|
+
}
|
|
16553
|
+
};
|
|
16554
|
+
|
|
16543
16555
|
// src/liquid/index.ts
|
|
16544
|
-
var
|
|
16556
|
+
var import_liquidjs25 = require("liquidjs");
|
|
16545
16557
|
|
|
16546
16558
|
// src/liquid/tags/assign.ts
|
|
16547
|
-
var
|
|
16559
|
+
var import_liquidjs6 = require("liquidjs");
|
|
16548
16560
|
function bind(_liquidSwell) {
|
|
16549
|
-
return class AssignTag extends
|
|
16561
|
+
return class AssignTag extends import_liquidjs6.Tag {
|
|
16550
16562
|
key;
|
|
16551
16563
|
value;
|
|
16552
16564
|
identifier;
|
|
@@ -16558,7 +16570,7 @@ function bind(_liquidSwell) {
|
|
|
16558
16570
|
this.tokenizer.skipBlank();
|
|
16559
16571
|
this.tokenizer.advance();
|
|
16560
16572
|
try {
|
|
16561
|
-
this.value = new
|
|
16573
|
+
this.value = new import_liquidjs6.Value(this.tokenizer.readFilteredValue(), this.liquid);
|
|
16562
16574
|
} catch (e) {
|
|
16563
16575
|
console.warn(
|
|
16564
16576
|
`Liquid "assign" tag: ${e instanceof Error ? e.stack : String(e)}`
|
|
@@ -16585,9 +16597,9 @@ function bind(_liquidSwell) {
|
|
|
16585
16597
|
}
|
|
16586
16598
|
|
|
16587
16599
|
// src/liquid/tags/case.ts
|
|
16588
|
-
var
|
|
16600
|
+
var import_liquidjs7 = require("liquidjs");
|
|
16589
16601
|
function bind2(liquidSwell) {
|
|
16590
|
-
return class CaseTag extends
|
|
16602
|
+
return class CaseTag extends import_liquidjs7.Tag {
|
|
16591
16603
|
value;
|
|
16592
16604
|
branches;
|
|
16593
16605
|
elseTemplates;
|
|
@@ -16598,7 +16610,7 @@ function bind2(liquidSwell) {
|
|
|
16598
16610
|
const caseVar = this.tokenizer.readValue()?.getText();
|
|
16599
16611
|
this.isBlock = Boolean(caseVar?.startsWith("block."));
|
|
16600
16612
|
this.tokenizer.p = begin;
|
|
16601
|
-
this.value = new
|
|
16613
|
+
this.value = new import_liquidjs7.Value(this.tokenizer.readFilteredValue(), this.liquid);
|
|
16602
16614
|
this.branches = [];
|
|
16603
16615
|
this.elseTemplates = [];
|
|
16604
16616
|
let p = [];
|
|
@@ -16636,12 +16648,12 @@ function bind2(liquidSwell) {
|
|
|
16636
16648
|
}
|
|
16637
16649
|
*render(ctx, emitter) {
|
|
16638
16650
|
const r = this.liquid.renderer;
|
|
16639
|
-
const target = (0,
|
|
16651
|
+
const target = (0, import_liquidjs7.toValue)(yield this.value.value(ctx, ctx.opts.lenientIf));
|
|
16640
16652
|
let branchHit = false;
|
|
16641
16653
|
let output = "";
|
|
16642
16654
|
for (const branch of this.branches) {
|
|
16643
16655
|
for (const valueToken of branch.values) {
|
|
16644
|
-
const value = yield (0,
|
|
16656
|
+
const value = yield (0, import_liquidjs7.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
|
|
16645
16657
|
if (target === value) {
|
|
16646
16658
|
const blockOutput = yield r.renderTemplates(branch.templates, ctx);
|
|
16647
16659
|
output += this.isBlock && liquidSwell.isEditor ? `<span class="swell-block">${blockOutput}</span>` : blockOutput;
|
|
@@ -16674,15 +16686,15 @@ function bind2(liquidSwell) {
|
|
|
16674
16686
|
}
|
|
16675
16687
|
|
|
16676
16688
|
// src/liquid/tags/comment.ts
|
|
16677
|
-
var
|
|
16689
|
+
var import_liquidjs8 = require("liquidjs");
|
|
16678
16690
|
function bind3(_liquidSwell) {
|
|
16679
|
-
return class CommentTag extends
|
|
16691
|
+
return class CommentTag extends import_liquidjs8.Tag {
|
|
16680
16692
|
constructor(tagToken, remainTokens, liquid) {
|
|
16681
16693
|
super(tagToken, remainTokens, liquid);
|
|
16682
16694
|
let nested = 1;
|
|
16683
16695
|
while (remainTokens.length > 0) {
|
|
16684
16696
|
const token = remainTokens.shift();
|
|
16685
|
-
if (
|
|
16697
|
+
if (import_liquidjs8.TypeGuards.isTagToken(token)) {
|
|
16686
16698
|
switch (token.name) {
|
|
16687
16699
|
case "comment":
|
|
16688
16700
|
nested += 1;
|
|
@@ -16707,13 +16719,13 @@ function bind3(_liquidSwell) {
|
|
|
16707
16719
|
}
|
|
16708
16720
|
|
|
16709
16721
|
// src/liquid/tags/for.ts
|
|
16710
|
-
var
|
|
16722
|
+
var import_liquidjs9 = require("liquidjs");
|
|
16711
16723
|
var MODIFIERS = Object.freeze(["offset", "limit", "reversed"]);
|
|
16712
16724
|
function bind4(_liquidSwell) {
|
|
16713
|
-
return class ForTag extends
|
|
16725
|
+
return class ForTag extends import_liquidjs9.ForTag {
|
|
16714
16726
|
*render(ctx, emitter) {
|
|
16715
16727
|
const r = this.liquid.renderer;
|
|
16716
|
-
let collection = yield (0,
|
|
16728
|
+
let collection = yield (0, import_liquidjs9.evalToken)(this.collection, ctx);
|
|
16717
16729
|
collection = yield resolveEnumerable(collection);
|
|
16718
16730
|
if (!collection.length) {
|
|
16719
16731
|
yield r.renderTemplates(this.elseTemplates, ctx, emitter);
|
|
@@ -16768,10 +16780,10 @@ function limit(arr, count) {
|
|
|
16768
16780
|
}
|
|
16769
16781
|
|
|
16770
16782
|
// src/liquid/tags/form.ts
|
|
16771
|
-
var
|
|
16783
|
+
var import_liquidjs10 = require("liquidjs");
|
|
16772
16784
|
var IGNORED_SHOPIFY_FORMS = Object.freeze(["new_comment", "guest_login"]);
|
|
16773
16785
|
function bind5(liquidSwell) {
|
|
16774
|
-
return class FormTag extends
|
|
16786
|
+
return class FormTag extends import_liquidjs10.Tag {
|
|
16775
16787
|
formType;
|
|
16776
16788
|
formConfig;
|
|
16777
16789
|
templates;
|
|
@@ -16785,10 +16797,10 @@ function bind5(liquidSwell) {
|
|
|
16785
16797
|
tokenizer.advance();
|
|
16786
16798
|
this.arg = tokenizer.readValue();
|
|
16787
16799
|
this.templates = [];
|
|
16788
|
-
this.hash = new
|
|
16800
|
+
this.hash = new import_liquidjs10.Hash(this.tokenizer.remaining());
|
|
16789
16801
|
while (remainTokens.length > 0) {
|
|
16790
16802
|
const token2 = remainTokens.shift();
|
|
16791
|
-
if (
|
|
16803
|
+
if (import_liquidjs10.TypeGuards.isTagToken(token2) && token2.name === "endform") {
|
|
16792
16804
|
return;
|
|
16793
16805
|
}
|
|
16794
16806
|
this.templates.push(parser.parseToken(token2, remainTokens));
|
|
@@ -16806,7 +16818,7 @@ function bind5(liquidSwell) {
|
|
|
16806
16818
|
return;
|
|
16807
16819
|
}
|
|
16808
16820
|
const r = this.liquid.renderer;
|
|
16809
|
-
const arg = yield (0,
|
|
16821
|
+
const arg = yield (0, import_liquidjs10.evalToken)(this.arg, ctx);
|
|
16810
16822
|
const hash = yield this.hash.render(ctx);
|
|
16811
16823
|
const scope = ctx.getAll();
|
|
16812
16824
|
const attrs = " " + Object.entries(hash).reduce((acc, [key, value]) => {
|
|
@@ -16866,9 +16878,9 @@ function bind5(liquidSwell) {
|
|
|
16866
16878
|
}
|
|
16867
16879
|
|
|
16868
16880
|
// src/liquid/tags/if.ts
|
|
16869
|
-
var
|
|
16881
|
+
var import_liquidjs11 = require("liquidjs");
|
|
16870
16882
|
function bind6(_liquidSwell) {
|
|
16871
|
-
return class IfTag extends
|
|
16883
|
+
return class IfTag extends import_liquidjs11.Tag {
|
|
16872
16884
|
branches = [];
|
|
16873
16885
|
elseTemplates;
|
|
16874
16886
|
constructor(tagToken, remainTokens, liquid, parser) {
|
|
@@ -16877,22 +16889,22 @@ function bind6(_liquidSwell) {
|
|
|
16877
16889
|
parser.parseStream(remainTokens).on(
|
|
16878
16890
|
"start",
|
|
16879
16891
|
() => this.branches.push({
|
|
16880
|
-
value: new
|
|
16892
|
+
value: new import_liquidjs11.Value(
|
|
16881
16893
|
tagToken.tokenizer.readFilteredValue(),
|
|
16882
16894
|
this.liquid
|
|
16883
16895
|
),
|
|
16884
16896
|
templates: p = []
|
|
16885
16897
|
})
|
|
16886
16898
|
).on("tag:elsif", (token) => {
|
|
16887
|
-
(0,
|
|
16899
|
+
(0, import_liquidjs11.assert)(!this.elseTemplates, "unexpected elsif after else");
|
|
16888
16900
|
this.branches.push({
|
|
16889
|
-
value: new
|
|
16901
|
+
value: new import_liquidjs11.Value(token.tokenizer.readFilteredValue(), this.liquid),
|
|
16890
16902
|
templates: p = []
|
|
16891
16903
|
});
|
|
16892
16904
|
}).on("tag:else", (tag) => {
|
|
16893
16905
|
if (tag.args.length > 0) {
|
|
16894
16906
|
this.branches.push({
|
|
16895
|
-
value: new
|
|
16907
|
+
value: new import_liquidjs11.Value(tag.tokenizer.readFilteredValue(), this.liquid),
|
|
16896
16908
|
templates: p = []
|
|
16897
16909
|
});
|
|
16898
16910
|
} else {
|
|
@@ -16910,7 +16922,7 @@ function bind6(_liquidSwell) {
|
|
|
16910
16922
|
const r = this.liquid.renderer;
|
|
16911
16923
|
for (const { value, templates } of this.branches) {
|
|
16912
16924
|
const v = yield value.value(ctx, ctx.opts.lenientIf);
|
|
16913
|
-
if ((0,
|
|
16925
|
+
if ((0, import_liquidjs11.isTruthy)(v, ctx)) {
|
|
16914
16926
|
yield r.renderTemplates(templates, ctx, emitter);
|
|
16915
16927
|
return;
|
|
16916
16928
|
}
|
|
@@ -16931,20 +16943,20 @@ function bind6(_liquidSwell) {
|
|
|
16931
16943
|
};
|
|
16932
16944
|
}
|
|
16933
16945
|
function assertEmpty(predicate, message = `unexpected ${JSON.stringify(predicate)}`) {
|
|
16934
|
-
(0,
|
|
16946
|
+
(0, import_liquidjs11.assert)(!predicate, message);
|
|
16935
16947
|
}
|
|
16936
16948
|
|
|
16937
16949
|
// src/liquid/tags/javascript.ts
|
|
16938
|
-
var
|
|
16950
|
+
var import_liquidjs12 = require("liquidjs");
|
|
16939
16951
|
function bind7(_liquidSwell) {
|
|
16940
|
-
return class JavascriptTag extends
|
|
16952
|
+
return class JavascriptTag extends import_liquidjs12.Tag {
|
|
16941
16953
|
templates;
|
|
16942
16954
|
constructor(token, remainTokens, liquid, parser) {
|
|
16943
16955
|
super(token, remainTokens, liquid);
|
|
16944
16956
|
this.templates = [];
|
|
16945
16957
|
while (remainTokens.length > 0) {
|
|
16946
16958
|
const token2 = remainTokens.shift();
|
|
16947
|
-
if (
|
|
16959
|
+
if (import_liquidjs12.TypeGuards.isTagToken(token2) && token2.name === "endjavascript") {
|
|
16948
16960
|
return;
|
|
16949
16961
|
}
|
|
16950
16962
|
this.templates.push(parser.parseToken(token2, remainTokens));
|
|
@@ -16962,9 +16974,9 @@ function bind7(_liquidSwell) {
|
|
|
16962
16974
|
}
|
|
16963
16975
|
|
|
16964
16976
|
// src/liquid/tags/layout.ts
|
|
16965
|
-
var
|
|
16977
|
+
var import_liquidjs13 = require("liquidjs");
|
|
16966
16978
|
function bind8(liquidSwell) {
|
|
16967
|
-
return class LayoutTag extends
|
|
16979
|
+
return class LayoutTag extends import_liquidjs13.Tag {
|
|
16968
16980
|
fileName;
|
|
16969
16981
|
constructor(token, remainTokens, liquid, _parser) {
|
|
16970
16982
|
super(token, remainTokens, liquid);
|
|
@@ -16980,9 +16992,9 @@ function bind8(liquidSwell) {
|
|
|
16980
16992
|
}
|
|
16981
16993
|
|
|
16982
16994
|
// src/liquid/tags/paginate.ts
|
|
16983
|
-
var
|
|
16995
|
+
var import_liquidjs14 = require("liquidjs");
|
|
16984
16996
|
function bind9(liquidSwell) {
|
|
16985
|
-
return class PaginateTag extends
|
|
16997
|
+
return class PaginateTag extends import_liquidjs14.Tag {
|
|
16986
16998
|
collection;
|
|
16987
16999
|
pageSize;
|
|
16988
17000
|
templates;
|
|
@@ -16997,7 +17009,7 @@ function bind9(liquidSwell) {
|
|
|
16997
17009
|
}
|
|
16998
17010
|
this.templates = [];
|
|
16999
17011
|
this.collection = collection;
|
|
17000
|
-
this.hash = new
|
|
17012
|
+
this.hash = new import_liquidjs14.Hash(this.tokenizer.remaining());
|
|
17001
17013
|
const stream = parser.parseStream(remainTokens).on("tag:endpaginate", () => stream.stop()).on("template", (tpl) => {
|
|
17002
17014
|
this.templates.push(tpl);
|
|
17003
17015
|
}).on("end", () => {
|
|
@@ -17007,8 +17019,8 @@ function bind9(liquidSwell) {
|
|
|
17007
17019
|
}
|
|
17008
17020
|
*render(ctx, emitter) {
|
|
17009
17021
|
const r = this.liquid.renderer;
|
|
17010
|
-
const collection = yield (0,
|
|
17011
|
-
const pageSize = Number(yield (0,
|
|
17022
|
+
const collection = yield (0, import_liquidjs14.evalToken)(this.collection, ctx);
|
|
17023
|
+
const pageSize = Number(yield (0, import_liquidjs14.evalToken)(this.pageSize, ctx));
|
|
17012
17024
|
const hash = yield this.hash.render(ctx);
|
|
17013
17025
|
if (!Number.isNaN(pageSize) && collection instanceof SwellStorefrontCollection && collection.limit != pageSize) {
|
|
17014
17026
|
yield collection._get({
|
|
@@ -17032,9 +17044,9 @@ function bind9(liquidSwell) {
|
|
|
17032
17044
|
|
|
17033
17045
|
// src/liquid/tags/render.ts
|
|
17034
17046
|
var import_lodash_es8 = require("lodash-es");
|
|
17035
|
-
var
|
|
17047
|
+
var import_liquidjs15 = require("liquidjs");
|
|
17036
17048
|
function bind10(liquidSwell) {
|
|
17037
|
-
return class RenderTag extends
|
|
17049
|
+
return class RenderTag extends import_liquidjs15.RenderTag {
|
|
17038
17050
|
*render(ctx, emitter) {
|
|
17039
17051
|
const { liquid, hash } = this;
|
|
17040
17052
|
const filepath = yield renderFilePath(
|
|
@@ -17042,7 +17054,7 @@ function bind10(liquidSwell) {
|
|
|
17042
17054
|
ctx,
|
|
17043
17055
|
liquid
|
|
17044
17056
|
);
|
|
17045
|
-
(0,
|
|
17057
|
+
(0, import_liquidjs15.assert)(filepath, () => `illegal file path "${filepath}"`);
|
|
17046
17058
|
const themeConfig = yield liquidSwell.getComponentPath(filepath).then(
|
|
17047
17059
|
(fileName) => liquidSwell.getThemeConfig(fileName)
|
|
17048
17060
|
);
|
|
@@ -17054,11 +17066,11 @@ function bind10(liquidSwell) {
|
|
|
17054
17066
|
if (this["with"]) {
|
|
17055
17067
|
const { value, alias } = this["with"];
|
|
17056
17068
|
const aliasName = alias || filepath;
|
|
17057
|
-
scope[aliasName] = yield (0,
|
|
17069
|
+
scope[aliasName] = yield (0, import_liquidjs15.evalToken)(value, ctx);
|
|
17058
17070
|
}
|
|
17059
17071
|
if (this["for"]) {
|
|
17060
17072
|
const { value, alias } = this["for"];
|
|
17061
|
-
let collection = yield (0,
|
|
17073
|
+
let collection = yield (0, import_liquidjs15.evalToken)(value, ctx);
|
|
17062
17074
|
collection = yield resolveEnumerable(collection);
|
|
17063
17075
|
scope["forloop"] = new ForloopDrop(
|
|
17064
17076
|
collection.length,
|
|
@@ -17091,13 +17103,13 @@ function* renderFilePath(file, ctx, liquid) {
|
|
|
17091
17103
|
default:
|
|
17092
17104
|
break;
|
|
17093
17105
|
}
|
|
17094
|
-
return yield (0,
|
|
17106
|
+
return yield (0, import_liquidjs15.evalToken)(file, ctx);
|
|
17095
17107
|
}
|
|
17096
17108
|
|
|
17097
17109
|
// src/liquid/tags/section.ts
|
|
17098
|
-
var
|
|
17110
|
+
var import_liquidjs16 = require("liquidjs");
|
|
17099
17111
|
function bind11(liquidSwell) {
|
|
17100
|
-
return class SectionTag extends
|
|
17112
|
+
return class SectionTag extends import_liquidjs16.Tag {
|
|
17101
17113
|
fileName;
|
|
17102
17114
|
constructor(token, remainTokens, liquid, _parser) {
|
|
17103
17115
|
super(token, remainTokens, liquid);
|
|
@@ -17133,7 +17145,7 @@ function bind11(liquidSwell) {
|
|
|
17133
17145
|
}
|
|
17134
17146
|
});
|
|
17135
17147
|
});
|
|
17136
|
-
if (output) {
|
|
17148
|
+
if (output && schema && settings) {
|
|
17137
17149
|
const { shopify_compatibility: shopifyCompatibility } = liquidSwell.theme.globals;
|
|
17138
17150
|
const tag = schema.tag || "div";
|
|
17139
17151
|
const id = `${shopifyCompatibility ? "shopify" : "swell"}-section-${settings.id || this.fileName}`;
|
|
@@ -17147,10 +17159,10 @@ function bind11(liquidSwell) {
|
|
|
17147
17159
|
}
|
|
17148
17160
|
|
|
17149
17161
|
// src/liquid/tags/sections.ts
|
|
17150
|
-
var
|
|
17162
|
+
var import_liquidjs17 = require("liquidjs");
|
|
17151
17163
|
var import_json54 = __toESM(require("json5"), 1);
|
|
17152
17164
|
function bind12(liquidSwell) {
|
|
17153
|
-
return class SectionsTag extends
|
|
17165
|
+
return class SectionsTag extends import_liquidjs17.Tag {
|
|
17154
17166
|
fileName;
|
|
17155
17167
|
constructor(token, remainTokens, liquid, _parser) {
|
|
17156
17168
|
super(token, remainTokens, liquid);
|
|
@@ -17158,10 +17170,16 @@ function bind12(liquidSwell) {
|
|
|
17158
17170
|
this.fileName = tokenizer.readValue()?.content;
|
|
17159
17171
|
}
|
|
17160
17172
|
*render(_ctx, emitter) {
|
|
17161
|
-
const filePath = yield liquidSwell.getSectionGroupPath(
|
|
17162
|
-
|
|
17173
|
+
const filePath = yield liquidSwell.getSectionGroupPath(
|
|
17174
|
+
this.fileName
|
|
17175
|
+
);
|
|
17176
|
+
const themeConfig = yield liquidSwell.getThemeConfig(
|
|
17177
|
+
filePath
|
|
17178
|
+
);
|
|
17163
17179
|
try {
|
|
17164
|
-
const sectionGroup = import_json54.default.parse(
|
|
17180
|
+
const sectionGroup = import_json54.default.parse(
|
|
17181
|
+
themeConfig.file_data
|
|
17182
|
+
);
|
|
17165
17183
|
const sectionConfigs = yield liquidSwell.renderPageSections(
|
|
17166
17184
|
sectionGroup
|
|
17167
17185
|
);
|
|
@@ -17174,6 +17192,7 @@ function bind12(liquidSwell) {
|
|
|
17174
17192
|
return `<${tag} id="${id}" class="${className} ${section.class || ""}">${section.output}</${tag}>`;
|
|
17175
17193
|
}).join("")}</div>`
|
|
17176
17194
|
);
|
|
17195
|
+
yield liquidSwell.theme.addPageSection(this.fileName, true);
|
|
17177
17196
|
} catch (err) {
|
|
17178
17197
|
console.warn(err);
|
|
17179
17198
|
}
|
|
@@ -17182,9 +17201,9 @@ function bind12(liquidSwell) {
|
|
|
17182
17201
|
}
|
|
17183
17202
|
|
|
17184
17203
|
// src/liquid/tags/style.ts
|
|
17185
|
-
var
|
|
17204
|
+
var import_liquidjs18 = require("liquidjs");
|
|
17186
17205
|
function bind13(_liquidSwell) {
|
|
17187
|
-
return class StyleTag extends
|
|
17206
|
+
return class StyleTag extends import_liquidjs18.Tag {
|
|
17188
17207
|
templates;
|
|
17189
17208
|
hash;
|
|
17190
17209
|
constructor(token, remainTokens, liquid, parser) {
|
|
@@ -17193,7 +17212,7 @@ function bind13(_liquidSwell) {
|
|
|
17193
17212
|
this.templates = [];
|
|
17194
17213
|
while (remainTokens.length > 0) {
|
|
17195
17214
|
const token2 = remainTokens.shift();
|
|
17196
|
-
if (
|
|
17215
|
+
if (import_liquidjs18.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
|
|
17197
17216
|
return;
|
|
17198
17217
|
}
|
|
17199
17218
|
this.templates.push(parser.parseToken(token2, remainTokens));
|
|
@@ -17215,16 +17234,16 @@ function bind13(_liquidSwell) {
|
|
|
17215
17234
|
}
|
|
17216
17235
|
|
|
17217
17236
|
// src/liquid/tags/stylesheet.ts
|
|
17218
|
-
var
|
|
17237
|
+
var import_liquidjs19 = require("liquidjs");
|
|
17219
17238
|
function bind14(_liquidSwell) {
|
|
17220
|
-
return class StyleSheetTag extends
|
|
17239
|
+
return class StyleSheetTag extends import_liquidjs19.Tag {
|
|
17221
17240
|
templates;
|
|
17222
17241
|
constructor(token, remainTokens, liquid, parser) {
|
|
17223
17242
|
super(token, remainTokens, liquid);
|
|
17224
17243
|
this.templates = [];
|
|
17225
17244
|
while (remainTokens.length > 0) {
|
|
17226
17245
|
const token2 = remainTokens.shift();
|
|
17227
|
-
if (
|
|
17246
|
+
if (import_liquidjs19.TypeGuards.isTagToken(token2) && token2.name === "endstylesheet") {
|
|
17228
17247
|
return;
|
|
17229
17248
|
}
|
|
17230
17249
|
this.templates.push(parser.parseToken(token2, remainTokens));
|
|
@@ -17240,9 +17259,9 @@ function bind14(_liquidSwell) {
|
|
|
17240
17259
|
}
|
|
17241
17260
|
|
|
17242
17261
|
// src/liquid/tags/shopify/include.ts
|
|
17243
|
-
var
|
|
17262
|
+
var import_liquidjs20 = require("liquidjs");
|
|
17244
17263
|
function bind15(liquidSwell) {
|
|
17245
|
-
return class IncludeTag extends
|
|
17264
|
+
return class IncludeTag extends import_liquidjs20.IncludeTag {
|
|
17246
17265
|
*render(ctx, emitter) {
|
|
17247
17266
|
const { hash } = this;
|
|
17248
17267
|
const filepath = yield renderFilePath(
|
|
@@ -17250,13 +17269,13 @@ function bind15(liquidSwell) {
|
|
|
17250
17269
|
ctx,
|
|
17251
17270
|
this.liquid
|
|
17252
17271
|
);
|
|
17253
|
-
(0,
|
|
17272
|
+
(0, import_liquidjs20.assert)(filepath, () => `illegal file path "${filepath}"`);
|
|
17254
17273
|
const saved = ctx.saveRegister("blocks", "blockMode");
|
|
17255
17274
|
ctx.setRegister("blocks", {});
|
|
17256
17275
|
ctx.setRegister("blockMode", 0);
|
|
17257
17276
|
const scope = yield hash.render(ctx);
|
|
17258
17277
|
if (this.withVar) {
|
|
17259
|
-
scope[filepath] = yield (0,
|
|
17278
|
+
scope[filepath] = yield (0, import_liquidjs20.evalToken)(this.withVar, ctx);
|
|
17260
17279
|
}
|
|
17261
17280
|
ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
|
|
17262
17281
|
const output = yield liquidSwell.getComponentPath(filepath).then((path) => liquidSwell.getThemeConfig(path)).then((themeConfig) => liquidSwell.renderTemplate(themeConfig, scope));
|
|
@@ -17268,10 +17287,10 @@ function bind15(liquidSwell) {
|
|
|
17268
17287
|
}
|
|
17269
17288
|
|
|
17270
17289
|
// src/liquid/tags/shopify/schema.ts
|
|
17271
|
-
var
|
|
17290
|
+
var import_liquidjs21 = require("liquidjs");
|
|
17272
17291
|
var import_json55 = __toESM(require("json5"), 1);
|
|
17273
17292
|
function bind16(liquidSwell) {
|
|
17274
|
-
return class SchemaTag extends
|
|
17293
|
+
return class SchemaTag extends import_liquidjs21.Tag {
|
|
17275
17294
|
templates;
|
|
17276
17295
|
constructor(token, remainTokens, liquid, parser) {
|
|
17277
17296
|
super(token, remainTokens, liquid);
|
|
@@ -17304,9 +17323,9 @@ function bind16(liquidSwell) {
|
|
|
17304
17323
|
}
|
|
17305
17324
|
|
|
17306
17325
|
// src/liquid/tags/inline_editable.ts
|
|
17307
|
-
var
|
|
17326
|
+
var import_liquidjs22 = require("liquidjs");
|
|
17308
17327
|
function bind17(_liquidSwell) {
|
|
17309
|
-
return class InlineEditableTag extends
|
|
17328
|
+
return class InlineEditableTag extends import_liquidjs22.Tag {
|
|
17310
17329
|
key;
|
|
17311
17330
|
value;
|
|
17312
17331
|
constructor(token, remainTokens, liquid, _parser) {
|
|
@@ -18303,9 +18322,9 @@ async function resolveAsyncProps(propArg, resolveProps) {
|
|
|
18303
18322
|
}
|
|
18304
18323
|
|
|
18305
18324
|
// src/liquid/operators.ts
|
|
18306
|
-
var
|
|
18325
|
+
var import_liquidjs23 = require("liquidjs");
|
|
18307
18326
|
var swellOperators = {
|
|
18308
|
-
...
|
|
18327
|
+
...import_liquidjs23.defaultOperators,
|
|
18309
18328
|
"==": equal,
|
|
18310
18329
|
"!=": (l, r) => !equal(l, r),
|
|
18311
18330
|
contains: (l, r) => {
|
|
@@ -18332,8 +18351,8 @@ function arrayEqual(lhs, rhs) {
|
|
|
18332
18351
|
|
|
18333
18352
|
// src/liquid/color.ts
|
|
18334
18353
|
var import_color = __toESM(require("color"), 1);
|
|
18335
|
-
var
|
|
18336
|
-
var ThemeColor = class _ThemeColor extends
|
|
18354
|
+
var import_liquidjs24 = require("liquidjs");
|
|
18355
|
+
var ThemeColor = class _ThemeColor extends import_liquidjs24.Drop {
|
|
18337
18356
|
color;
|
|
18338
18357
|
colorValues;
|
|
18339
18358
|
red;
|
|
@@ -18468,7 +18487,7 @@ function isThemeColorLike(value) {
|
|
|
18468
18487
|
}
|
|
18469
18488
|
|
|
18470
18489
|
// src/liquid/index.ts
|
|
18471
|
-
var LiquidSwell30 = class extends
|
|
18490
|
+
var LiquidSwell30 = class extends import_liquidjs25.Liquid {
|
|
18472
18491
|
theme;
|
|
18473
18492
|
getThemeConfig;
|
|
18474
18493
|
getThemeTemplateConfigByType;
|
|
@@ -18900,6 +18919,7 @@ var SwellTheme3 = class {
|
|
|
18900
18919
|
globalData = {};
|
|
18901
18920
|
// Swell-native theme settings if not using Shopify compatibility
|
|
18902
18921
|
themeSettingFilePath = "theme/config/theme.json";
|
|
18922
|
+
pageSectionGroups = null;
|
|
18903
18923
|
constructor(swell, options = {}) {
|
|
18904
18924
|
const { forms, resources, globals, shopifyCompatibilityClass } = options;
|
|
18905
18925
|
this.swell = swell;
|
|
@@ -19791,9 +19811,10 @@ var SwellTheme3 = class {
|
|
|
19791
19811
|
}
|
|
19792
19812
|
return "";
|
|
19793
19813
|
}
|
|
19794
|
-
async renderLayout(data) {
|
|
19795
|
-
|
|
19796
|
-
|
|
19814
|
+
async renderLayout(layoutName, data) {
|
|
19815
|
+
layoutName = layoutName || this.liquidSwell.layoutName;
|
|
19816
|
+
if (layoutName) {
|
|
19817
|
+
return this.renderLayoutTemplate(layoutName, data);
|
|
19797
19818
|
} else {
|
|
19798
19819
|
return data?.content_for_layout || "";
|
|
19799
19820
|
}
|
|
@@ -19926,15 +19947,30 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19926
19947
|
}
|
|
19927
19948
|
return sectionConfigs;
|
|
19928
19949
|
}
|
|
19950
|
+
async addPageSection(sectionFileName, group) {
|
|
19951
|
+
if (this.pageSectionGroups === null) {
|
|
19952
|
+
return;
|
|
19953
|
+
}
|
|
19954
|
+
const { pageSectionGroups } = this;
|
|
19955
|
+
const sectionSchema = await this.getSectionSchema(sectionFileName);
|
|
19956
|
+
const sectionName = sectionSchema?.label || sectionFileName;
|
|
19957
|
+
let sourcePath = "";
|
|
19958
|
+
if (group) {
|
|
19959
|
+
const sectionConfig = await this.getThemeTemplateConfigByType(
|
|
19960
|
+
"sections",
|
|
19961
|
+
`${sectionFileName}.json`
|
|
19962
|
+
);
|
|
19963
|
+
sourcePath = sectionConfig?.file_path ?? "";
|
|
19964
|
+
}
|
|
19965
|
+
pageSectionGroups.push({
|
|
19966
|
+
prop: getSectionGroupProp(sectionFileName),
|
|
19967
|
+
label: sectionName,
|
|
19968
|
+
source: sourcePath,
|
|
19969
|
+
group
|
|
19970
|
+
});
|
|
19971
|
+
}
|
|
19929
19972
|
/**
|
|
19930
19973
|
* 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
19974
|
*/
|
|
19939
19975
|
async getPageSectionGroups(pageId) {
|
|
19940
19976
|
const pageConfig = await this.getThemeTemplateConfigByType(
|
|
@@ -19945,45 +19981,31 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19945
19981
|
return [];
|
|
19946
19982
|
}
|
|
19947
19983
|
const pageSchema = parseJsonConfig(pageConfig);
|
|
19948
|
-
const pageLayout = pageSchema.layout || "
|
|
19949
|
-
const
|
|
19950
|
-
|
|
19951
|
-
|
|
19952
|
-
|
|
19953
|
-
|
|
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({
|
|
19984
|
+
const pageLayout = pageSchema.layout || "";
|
|
19985
|
+
const pageSectionGroups = [];
|
|
19986
|
+
this.pageSectionGroups = pageSectionGroups;
|
|
19987
|
+
await this.renderLayout(pageLayout, {
|
|
19988
|
+
content_for_layout: new RenderDrop(() => {
|
|
19989
|
+
pageSectionGroups.push({
|
|
19977
19990
|
prop: SECTION_GROUP_CONTENT,
|
|
19978
19991
|
label: "Template",
|
|
19979
|
-
source: pageConfig.file_path
|
|
19992
|
+
source: pageConfig.file_path,
|
|
19993
|
+
group: true
|
|
19980
19994
|
});
|
|
19995
|
+
return "";
|
|
19996
|
+
})
|
|
19997
|
+
});
|
|
19998
|
+
this.pageSectionGroups = null;
|
|
19999
|
+
return pageSectionGroups;
|
|
20000
|
+
}
|
|
20001
|
+
async getLayoutSectionGroups(sectionGroups, resolveSettings = true) {
|
|
20002
|
+
const configs = /* @__PURE__ */ new Map();
|
|
20003
|
+
for (const sectionGroup of sectionGroups) {
|
|
20004
|
+
const config = await this.getThemeConfig(sectionGroup.source);
|
|
20005
|
+
if (config) {
|
|
20006
|
+
configs.set(config.file_path, config);
|
|
19981
20007
|
}
|
|
19982
20008
|
}
|
|
19983
|
-
return sections;
|
|
19984
|
-
}
|
|
19985
|
-
async getLayoutSectionGroups(resolveSettings = true) {
|
|
19986
|
-
const configs = await this.getThemeConfigsByPath("theme/sections/");
|
|
19987
20009
|
const layoutSectionGroups = await getLayoutSectionGroups(
|
|
19988
20010
|
configs,
|
|
19989
20011
|
this.getTemplateSchema.bind(this)
|