@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.mjs
CHANGED
|
@@ -8030,7 +8030,7 @@ function getEasyblocksPagePropsWithConfigs(themeGlobals, allSections, pageSectio
|
|
|
8030
8030
|
{
|
|
8031
8031
|
_id: "swell_page",
|
|
8032
8032
|
_component: "swell_page",
|
|
8033
|
-
|
|
8033
|
+
[SECTION_GROUP_CONTENT]: pageSections.filter((config) => componentSet.has(config.section.type)).map(({ section, settings, schema }) => ({
|
|
8034
8034
|
_id: prepareSectionId(section.id),
|
|
8035
8035
|
_component: section.type,
|
|
8036
8036
|
custom_css: settings?.section?.custom_css || "",
|
|
@@ -16409,6 +16409,18 @@ function ShopifyTemplate(_instance, template) {
|
|
|
16409
16409
|
);
|
|
16410
16410
|
}
|
|
16411
16411
|
|
|
16412
|
+
// src/compatibility/drops/render.ts
|
|
16413
|
+
import { Drop as Drop5 } from "liquidjs";
|
|
16414
|
+
var RenderDrop = class extends Drop5 {
|
|
16415
|
+
constructor(handler) {
|
|
16416
|
+
super();
|
|
16417
|
+
this.handler = handler;
|
|
16418
|
+
}
|
|
16419
|
+
valueOf() {
|
|
16420
|
+
return this.handler();
|
|
16421
|
+
}
|
|
16422
|
+
};
|
|
16423
|
+
|
|
16412
16424
|
// src/liquid/index.ts
|
|
16413
16425
|
import { Liquid as Liquid3 } from "liquidjs";
|
|
16414
16426
|
|
|
@@ -17010,7 +17022,7 @@ function bind11(liquidSwell) {
|
|
|
17010
17022
|
}
|
|
17011
17023
|
});
|
|
17012
17024
|
});
|
|
17013
|
-
if (output) {
|
|
17025
|
+
if (output && schema && settings) {
|
|
17014
17026
|
const { shopify_compatibility: shopifyCompatibility } = liquidSwell.theme.globals;
|
|
17015
17027
|
const tag = schema.tag || "div";
|
|
17016
17028
|
const id = `${shopifyCompatibility ? "shopify" : "swell"}-section-${settings.id || this.fileName}`;
|
|
@@ -17035,10 +17047,16 @@ function bind12(liquidSwell) {
|
|
|
17035
17047
|
this.fileName = tokenizer.readValue()?.content;
|
|
17036
17048
|
}
|
|
17037
17049
|
*render(_ctx, emitter) {
|
|
17038
|
-
const filePath = yield liquidSwell.getSectionGroupPath(
|
|
17039
|
-
|
|
17050
|
+
const filePath = yield liquidSwell.getSectionGroupPath(
|
|
17051
|
+
this.fileName
|
|
17052
|
+
);
|
|
17053
|
+
const themeConfig = yield liquidSwell.getThemeConfig(
|
|
17054
|
+
filePath
|
|
17055
|
+
);
|
|
17040
17056
|
try {
|
|
17041
|
-
const sectionGroup = JSON54.parse(
|
|
17057
|
+
const sectionGroup = JSON54.parse(
|
|
17058
|
+
themeConfig.file_data
|
|
17059
|
+
);
|
|
17042
17060
|
const sectionConfigs = yield liquidSwell.renderPageSections(
|
|
17043
17061
|
sectionGroup
|
|
17044
17062
|
);
|
|
@@ -17051,6 +17069,7 @@ function bind12(liquidSwell) {
|
|
|
17051
17069
|
return `<${tag} id="${id}" class="${className} ${section.class || ""}">${section.output}</${tag}>`;
|
|
17052
17070
|
}).join("")}</div>`
|
|
17053
17071
|
);
|
|
17072
|
+
yield liquidSwell.theme.addPageSection(this.fileName, true);
|
|
17054
17073
|
} catch (err) {
|
|
17055
17074
|
console.warn(err);
|
|
17056
17075
|
}
|
|
@@ -18209,8 +18228,8 @@ function arrayEqual(lhs, rhs) {
|
|
|
18209
18228
|
|
|
18210
18229
|
// src/liquid/color.ts
|
|
18211
18230
|
import Color from "color";
|
|
18212
|
-
import { Drop as
|
|
18213
|
-
var ThemeColor = class _ThemeColor extends
|
|
18231
|
+
import { Drop as Drop6 } from "liquidjs";
|
|
18232
|
+
var ThemeColor = class _ThemeColor extends Drop6 {
|
|
18214
18233
|
color;
|
|
18215
18234
|
colorValues;
|
|
18216
18235
|
red;
|
|
@@ -18777,6 +18796,7 @@ var SwellTheme3 = class {
|
|
|
18777
18796
|
globalData = {};
|
|
18778
18797
|
// Swell-native theme settings if not using Shopify compatibility
|
|
18779
18798
|
themeSettingFilePath = "theme/config/theme.json";
|
|
18799
|
+
pageSectionGroups = null;
|
|
18780
18800
|
constructor(swell, options = {}) {
|
|
18781
18801
|
const { forms, resources, globals, shopifyCompatibilityClass } = options;
|
|
18782
18802
|
this.swell = swell;
|
|
@@ -19668,9 +19688,10 @@ var SwellTheme3 = class {
|
|
|
19668
19688
|
}
|
|
19669
19689
|
return "";
|
|
19670
19690
|
}
|
|
19671
|
-
async renderLayout(data) {
|
|
19672
|
-
|
|
19673
|
-
|
|
19691
|
+
async renderLayout(layoutName, data) {
|
|
19692
|
+
layoutName = layoutName || this.liquidSwell.layoutName;
|
|
19693
|
+
if (layoutName) {
|
|
19694
|
+
return this.renderLayoutTemplate(layoutName, data);
|
|
19674
19695
|
} else {
|
|
19675
19696
|
return data?.content_for_layout || "";
|
|
19676
19697
|
}
|
|
@@ -19803,15 +19824,30 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19803
19824
|
}
|
|
19804
19825
|
return sectionConfigs;
|
|
19805
19826
|
}
|
|
19827
|
+
async addPageSection(sectionFileName, group) {
|
|
19828
|
+
if (this.pageSectionGroups === null) {
|
|
19829
|
+
return;
|
|
19830
|
+
}
|
|
19831
|
+
const { pageSectionGroups } = this;
|
|
19832
|
+
const sectionSchema = await this.getSectionSchema(sectionFileName);
|
|
19833
|
+
const sectionName = sectionSchema?.label || sectionFileName;
|
|
19834
|
+
let sourcePath = "";
|
|
19835
|
+
if (group) {
|
|
19836
|
+
const sectionConfig = await this.getThemeTemplateConfigByType(
|
|
19837
|
+
"sections",
|
|
19838
|
+
`${sectionFileName}.json`
|
|
19839
|
+
);
|
|
19840
|
+
sourcePath = sectionConfig?.file_path ?? "";
|
|
19841
|
+
}
|
|
19842
|
+
pageSectionGroups.push({
|
|
19843
|
+
prop: getSectionGroupProp(sectionFileName),
|
|
19844
|
+
label: sectionName,
|
|
19845
|
+
source: sourcePath,
|
|
19846
|
+
group
|
|
19847
|
+
});
|
|
19848
|
+
}
|
|
19806
19849
|
/**
|
|
19807
19850
|
* Get a list of sections and section groups in a page layout.
|
|
19808
|
-
*
|
|
19809
|
-
* Basically we should get these section groups: `header`, `content` and `footer`.
|
|
19810
|
-
* For now, section groups are searched for using regex in the page layout.
|
|
19811
|
-
* There may be cases where section groups can be nested in other files,
|
|
19812
|
-
* in which case they will not be visible to this function.
|
|
19813
|
-
*
|
|
19814
|
-
* In the future, we may use a dummy page renderer and thus extract all section groups.
|
|
19815
19851
|
*/
|
|
19816
19852
|
async getPageSectionGroups(pageId) {
|
|
19817
19853
|
const pageConfig = await this.getThemeTemplateConfigByType(
|
|
@@ -19822,45 +19858,31 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
19822
19858
|
return [];
|
|
19823
19859
|
}
|
|
19824
19860
|
const pageSchema = parseJsonConfig(pageConfig);
|
|
19825
|
-
const pageLayout = pageSchema.layout || "
|
|
19826
|
-
const
|
|
19827
|
-
|
|
19828
|
-
|
|
19829
|
-
|
|
19830
|
-
|
|
19831
|
-
return [];
|
|
19832
|
-
}
|
|
19833
|
-
const layoutData = layoutConfig.file_data;
|
|
19834
|
-
const iterator = layoutData.matchAll(
|
|
19835
|
-
/\bsections '(\w.*?)'|(\bcontent_for_layout\b)/gm
|
|
19836
|
-
);
|
|
19837
|
-
const sections = [];
|
|
19838
|
-
for (const match of iterator) {
|
|
19839
|
-
if (match[1]) {
|
|
19840
|
-
const sectionFileName = match[1] || match[2];
|
|
19841
|
-
const sectionSchema = await this.getSectionSchema(sectionFileName);
|
|
19842
|
-
const sectionName = sectionSchema?.label || sectionFileName;
|
|
19843
|
-
const sectionConfig = await this.getThemeTemplateConfigByType(
|
|
19844
|
-
"sections",
|
|
19845
|
-
`${sectionFileName}.json`
|
|
19846
|
-
);
|
|
19847
|
-
sections.push({
|
|
19848
|
-
prop: getSectionGroupProp(sectionFileName),
|
|
19849
|
-
label: sectionName,
|
|
19850
|
-
source: sectionConfig?.file_path
|
|
19851
|
-
});
|
|
19852
|
-
} else if (match[2]) {
|
|
19853
|
-
sections.push({
|
|
19861
|
+
const pageLayout = pageSchema.layout || "";
|
|
19862
|
+
const pageSectionGroups = [];
|
|
19863
|
+
this.pageSectionGroups = pageSectionGroups;
|
|
19864
|
+
await this.renderLayout(pageLayout, {
|
|
19865
|
+
content_for_layout: new RenderDrop(() => {
|
|
19866
|
+
pageSectionGroups.push({
|
|
19854
19867
|
prop: SECTION_GROUP_CONTENT,
|
|
19855
19868
|
label: "Template",
|
|
19856
|
-
source: pageConfig.file_path
|
|
19869
|
+
source: pageConfig.file_path,
|
|
19870
|
+
group: true
|
|
19857
19871
|
});
|
|
19872
|
+
return "";
|
|
19873
|
+
})
|
|
19874
|
+
});
|
|
19875
|
+
this.pageSectionGroups = null;
|
|
19876
|
+
return pageSectionGroups;
|
|
19877
|
+
}
|
|
19878
|
+
async getLayoutSectionGroups(sectionGroups, resolveSettings = true) {
|
|
19879
|
+
const configs = /* @__PURE__ */ new Map();
|
|
19880
|
+
for (const sectionGroup of sectionGroups) {
|
|
19881
|
+
const config = await this.getThemeConfig(sectionGroup.source);
|
|
19882
|
+
if (config) {
|
|
19883
|
+
configs.set(config.file_path, config);
|
|
19858
19884
|
}
|
|
19859
19885
|
}
|
|
19860
|
-
return sections;
|
|
19861
|
-
}
|
|
19862
|
-
async getLayoutSectionGroups(resolveSettings = true) {
|
|
19863
|
-
const configs = await this.getThemeConfigsByPath("theme/sections/");
|
|
19864
19886
|
const layoutSectionGroups = await getLayoutSectionGroups(
|
|
19865
19887
|
configs,
|
|
19866
19888
|
this.getTemplateSchema.bind(this)
|