@swell/apps-sdk 1.0.179 → 1.0.181
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 +114 -103
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +110 -101
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +114 -104
- package/dist/index.mjs.map +3 -3
- package/dist/src/compatibility/shopify.d.ts +1 -1
- package/dist/src/easyblocks/index.d.ts +1 -1
- package/dist/src/easyblocks/utils.d.ts +1 -0
- package/dist/src/liquid/filters/image_url.d.ts +1 -0
- package/dist/src/liquid/filters/shopify/img_url.d.ts +1 -1
- package/dist/types/swell.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -151,7 +151,8 @@ __export(index_exports, {
|
|
|
151
151
|
scopeCustomCSS: () => scopeCustomCSS,
|
|
152
152
|
stringifyQueryParams: () => stringifyQueryParams,
|
|
153
153
|
systemFonts: () => systemFonts,
|
|
154
|
-
toBase64: () => toBase64
|
|
154
|
+
toBase64: () => toBase64,
|
|
155
|
+
toBlockId: () => toBlockId
|
|
155
156
|
});
|
|
156
157
|
module.exports = __toCommonJS(index_exports);
|
|
157
158
|
|
|
@@ -3401,7 +3402,7 @@ function getSectionSettingsFromProps(props, sectionSchema) {
|
|
|
3401
3402
|
(block) => block.type === blockType
|
|
3402
3403
|
);
|
|
3403
3404
|
return {
|
|
3404
|
-
id,
|
|
3405
|
+
id: toBlockId(id),
|
|
3405
3406
|
type: blockType,
|
|
3406
3407
|
disabled: isDisabled,
|
|
3407
3408
|
settings: blockSchema?.fields?.reduce(
|
|
@@ -3430,6 +3431,12 @@ function toSchemaFieldId(fieldId) {
|
|
|
3430
3431
|
}
|
|
3431
3432
|
return fieldId.replace(/·/g, ".");
|
|
3432
3433
|
}
|
|
3434
|
+
function toBlockId(id) {
|
|
3435
|
+
if (!id) {
|
|
3436
|
+
return id;
|
|
3437
|
+
}
|
|
3438
|
+
return id.replace(/\./g, "_");
|
|
3439
|
+
}
|
|
3433
3440
|
|
|
3434
3441
|
// src/utils/md5.ts
|
|
3435
3442
|
function md5(inputString) {
|
|
@@ -5902,86 +5909,76 @@ function prepareSectionId(id) {
|
|
|
5902
5909
|
}
|
|
5903
5910
|
function getAllSectionComponentTemplates(allSections) {
|
|
5904
5911
|
const list = [];
|
|
5912
|
+
const processFields = (fields, settings = {}) => {
|
|
5913
|
+
const result = {};
|
|
5914
|
+
for (const field of fields) {
|
|
5915
|
+
if (!field?.id) {
|
|
5916
|
+
continue;
|
|
5917
|
+
}
|
|
5918
|
+
const { id: fieldId, $locale } = field;
|
|
5919
|
+
result[fieldId] = schemaToEasyblocksValue(
|
|
5920
|
+
fields,
|
|
5921
|
+
fieldId,
|
|
5922
|
+
settings[fieldId]
|
|
5923
|
+
);
|
|
5924
|
+
if ($locale) {
|
|
5925
|
+
for (const [locale, localeValues] of Object.entries($locale)) {
|
|
5926
|
+
const defaultValue = localeValues?.default;
|
|
5927
|
+
if (defaultValue) {
|
|
5928
|
+
(0, import_lodash_es4.set)(result, `$locale.${locale}.${fieldId}`, defaultValue);
|
|
5929
|
+
}
|
|
5930
|
+
}
|
|
5931
|
+
}
|
|
5932
|
+
}
|
|
5933
|
+
return result;
|
|
5934
|
+
};
|
|
5905
5935
|
for (const section of allSections) {
|
|
5906
5936
|
if (section.presets) {
|
|
5907
|
-
|
|
5908
|
-
|
|
5937
|
+
for (let index = 0; index < section.presets.length; index++) {
|
|
5938
|
+
const preset = section.presets[index];
|
|
5939
|
+
const entry = {
|
|
5940
|
+
_id: `${section.id}__preset_${index}`,
|
|
5941
|
+
_component: section.id,
|
|
5942
|
+
custom_css: preset.settings?.["custom_css"] || "",
|
|
5943
|
+
...processFields(section.fields, preset.settings),
|
|
5944
|
+
// Process blocks inside the preset
|
|
5945
|
+
Blocks: (preset.blocks || []).map((block) => {
|
|
5946
|
+
const blockSchema = section.blocks?.find(
|
|
5947
|
+
({ type }) => type === block.type
|
|
5948
|
+
);
|
|
5949
|
+
if (!blockSchema) {
|
|
5950
|
+
return null;
|
|
5951
|
+
}
|
|
5952
|
+
return {
|
|
5953
|
+
_id: `Block__${section.id}__${block.type}__preset_${index}`,
|
|
5954
|
+
_component: `Block__${section.id}__${block.type}`,
|
|
5955
|
+
...processFields(blockSchema.fields, block.settings)
|
|
5956
|
+
};
|
|
5957
|
+
}).filter(Boolean)
|
|
5958
|
+
};
|
|
5959
|
+
list.push({
|
|
5909
5960
|
id: `${section.id}__preset_${index}`,
|
|
5910
|
-
entry
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
custom_css: preset.settings?.["custom_css"] || "",
|
|
5914
|
-
...(0, import_lodash_es4.reduce)(
|
|
5915
|
-
section.fields,
|
|
5916
|
-
(acc, field) => {
|
|
5917
|
-
if (field.id) {
|
|
5918
|
-
acc[field.id] = schemaToEasyblocksValue(
|
|
5919
|
-
section.fields,
|
|
5920
|
-
field.id,
|
|
5921
|
-
preset.settings?.[field.id]
|
|
5922
|
-
);
|
|
5923
|
-
}
|
|
5924
|
-
return acc;
|
|
5925
|
-
},
|
|
5926
|
-
{}
|
|
5927
|
-
),
|
|
5928
|
-
Blocks: preset.blocks?.reduce(
|
|
5929
|
-
(acc, block) => {
|
|
5930
|
-
const blockDef = section.blocks?.find(
|
|
5931
|
-
({ type }) => type === block.type
|
|
5932
|
-
);
|
|
5933
|
-
if (blockDef) {
|
|
5934
|
-
acc.push({
|
|
5935
|
-
_id: `Block__${section.id}__${block.type}__preset_${index}`,
|
|
5936
|
-
_component: `Block__${section.id}__${block.type}`,
|
|
5937
|
-
...(0, import_lodash_es4.reduce)(
|
|
5938
|
-
blockDef.fields,
|
|
5939
|
-
(acc2, blockField) => {
|
|
5940
|
-
if (blockField.id) {
|
|
5941
|
-
acc2[blockField.id] = schemaToEasyblocksValue(
|
|
5942
|
-
blockDef.fields,
|
|
5943
|
-
blockField.id,
|
|
5944
|
-
block.settings?.[blockField.id]
|
|
5945
|
-
);
|
|
5946
|
-
}
|
|
5947
|
-
return acc2;
|
|
5948
|
-
},
|
|
5949
|
-
{}
|
|
5950
|
-
)
|
|
5951
|
-
});
|
|
5952
|
-
}
|
|
5953
|
-
return acc;
|
|
5954
|
-
},
|
|
5955
|
-
[]
|
|
5956
|
-
)
|
|
5957
|
-
}
|
|
5958
|
-
}))
|
|
5959
|
-
);
|
|
5961
|
+
entry
|
|
5962
|
+
});
|
|
5963
|
+
}
|
|
5960
5964
|
}
|
|
5961
5965
|
if (section.blocks) {
|
|
5962
|
-
|
|
5963
|
-
|
|
5966
|
+
for (const block of section.blocks) {
|
|
5967
|
+
list.push({
|
|
5964
5968
|
id: `Block__${section.id}__${block.type}`,
|
|
5965
5969
|
entry: {
|
|
5966
5970
|
_id: `Block__${section.id}__${block.type}`,
|
|
5967
5971
|
_component: `Block__${section.id}__${block.type}`,
|
|
5968
|
-
...(
|
|
5972
|
+
...processFields(
|
|
5969
5973
|
block.fields,
|
|
5970
|
-
(acc,
|
|
5971
|
-
if (
|
|
5972
|
-
acc[field.id] = schemaToEasyblocksValue(
|
|
5973
|
-
block.fields,
|
|
5974
|
-
field.id,
|
|
5975
|
-
field.default
|
|
5976
|
-
);
|
|
5977
|
-
}
|
|
5974
|
+
block.fields.reduce((acc, f) => {
|
|
5975
|
+
if (f.id) acc[f.id] = f.default;
|
|
5978
5976
|
return acc;
|
|
5979
|
-
},
|
|
5980
|
-
{}
|
|
5977
|
+
}, {})
|
|
5981
5978
|
)
|
|
5982
5979
|
}
|
|
5983
|
-
})
|
|
5984
|
-
|
|
5980
|
+
});
|
|
5981
|
+
}
|
|
5985
5982
|
}
|
|
5986
5983
|
}
|
|
5987
5984
|
return list;
|
|
@@ -11701,16 +11698,16 @@ function ShopifyBlog(instance, blogCategory) {
|
|
|
11701
11698
|
if (!Array.isArray(blogs?.results)) {
|
|
11702
11699
|
return [];
|
|
11703
11700
|
}
|
|
11704
|
-
const
|
|
11705
|
-
(
|
|
11701
|
+
const set3 = blogs.results.reduce(
|
|
11702
|
+
(set4, blog) => {
|
|
11706
11703
|
for (const tag of blog.tags || []) {
|
|
11707
|
-
|
|
11704
|
+
set4.add(tag);
|
|
11708
11705
|
}
|
|
11709
|
-
return
|
|
11706
|
+
return set4;
|
|
11710
11707
|
},
|
|
11711
11708
|
/* @__PURE__ */ new Set()
|
|
11712
11709
|
);
|
|
11713
|
-
return Array.from(
|
|
11710
|
+
return Array.from(set3.values());
|
|
11714
11711
|
});
|
|
11715
11712
|
return new ShopifyResource({
|
|
11716
11713
|
all_tags: allTags,
|
|
@@ -12094,18 +12091,18 @@ function ShopifyCollection(instance, category) {
|
|
|
12094
12091
|
if (!resolved) {
|
|
12095
12092
|
return [];
|
|
12096
12093
|
}
|
|
12097
|
-
const
|
|
12094
|
+
const set3 = /* @__PURE__ */ new Set();
|
|
12098
12095
|
await Promise.all(
|
|
12099
12096
|
resolved.results.map(async (product) => {
|
|
12100
12097
|
const tags2 = await Promise.resolve().then(() => product.tags);
|
|
12101
12098
|
if (Array.isArray(tags2)) {
|
|
12102
12099
|
for (const tag of tags2) {
|
|
12103
|
-
|
|
12100
|
+
set3.add(tag);
|
|
12104
12101
|
}
|
|
12105
12102
|
}
|
|
12106
12103
|
})
|
|
12107
12104
|
);
|
|
12108
|
-
return Array.from(
|
|
12105
|
+
return Array.from(set3.values());
|
|
12109
12106
|
}),
|
|
12110
12107
|
all_types: defer(async () => {
|
|
12111
12108
|
const products = await resolveProducts();
|
|
@@ -14455,26 +14452,32 @@ ${injects.join("\n")}</script>`;
|
|
|
14455
14452
|
if (!(0, import_lodash_es7.isObject)(schema)) {
|
|
14456
14453
|
return schema;
|
|
14457
14454
|
}
|
|
14458
|
-
const
|
|
14459
|
-
|
|
14460
|
-
localeCode
|
|
14461
|
-
|
|
14455
|
+
const locales = await theme.swell.storefront.locale.list();
|
|
14456
|
+
const localeCodes = /* @__PURE__ */ new Set([
|
|
14457
|
+
localeCode,
|
|
14458
|
+
...locales.map((locale) => locale.code)
|
|
14459
|
+
]);
|
|
14460
|
+
const localeConfigs = {};
|
|
14461
|
+
for (const locale of localeCodes) {
|
|
14462
|
+
localeConfigs[locale] = await this.getEditorLocaleConfig(theme, locale);
|
|
14463
|
+
}
|
|
14462
14464
|
return this.renderSchemaTranslationValue(
|
|
14463
14465
|
theme,
|
|
14464
14466
|
schema,
|
|
14465
14467
|
localeCode,
|
|
14466
|
-
|
|
14468
|
+
localeConfigs
|
|
14467
14469
|
);
|
|
14468
14470
|
}
|
|
14469
|
-
|
|
14471
|
+
renderSchemaTranslationValue(theme, schemaValue, localeCode, localeConfigs) {
|
|
14470
14472
|
switch (typeof schemaValue) {
|
|
14471
14473
|
case "string": {
|
|
14472
14474
|
if (schemaValue.startsWith("t:")) {
|
|
14475
|
+
const localeConfig = localeConfigs[localeCode];
|
|
14473
14476
|
const key = schemaValue.slice(2);
|
|
14474
14477
|
const keyParts = key?.split(".");
|
|
14475
14478
|
const keyName = keyParts.pop() || "";
|
|
14476
14479
|
const keyPath = keyParts.join(".");
|
|
14477
|
-
const langObject = (0, import_lodash_es7.get)(
|
|
14480
|
+
const langObject = (0, import_lodash_es7.get)(localeConfig, keyPath);
|
|
14478
14481
|
return langObject?.[keyName] ?? key;
|
|
14479
14482
|
}
|
|
14480
14483
|
break;
|
|
@@ -14484,11 +14487,11 @@ ${injects.join("\n")}</script>`;
|
|
|
14484
14487
|
const result = [];
|
|
14485
14488
|
for (const value of schemaValue) {
|
|
14486
14489
|
result.push(
|
|
14487
|
-
|
|
14490
|
+
this.renderSchemaTranslationValue(
|
|
14488
14491
|
theme,
|
|
14489
14492
|
value,
|
|
14490
|
-
|
|
14491
|
-
|
|
14493
|
+
localeCode,
|
|
14494
|
+
localeConfigs
|
|
14492
14495
|
)
|
|
14493
14496
|
);
|
|
14494
14497
|
}
|
|
@@ -14497,12 +14500,26 @@ ${injects.join("\n")}</script>`;
|
|
|
14497
14500
|
if (schemaValue !== null) {
|
|
14498
14501
|
const result = { ...schemaValue };
|
|
14499
14502
|
for (const [key, value] of Object.entries(schemaValue)) {
|
|
14500
|
-
result[key] =
|
|
14503
|
+
result[key] = this.renderSchemaTranslationValue(
|
|
14501
14504
|
theme,
|
|
14502
14505
|
value,
|
|
14503
|
-
|
|
14504
|
-
|
|
14506
|
+
localeCode,
|
|
14507
|
+
localeConfigs
|
|
14505
14508
|
);
|
|
14509
|
+
if (typeof value === "string" && value.startsWith("t:")) {
|
|
14510
|
+
for (const locale of Object.keys(localeConfigs)) {
|
|
14511
|
+
if (locale === localeCode) {
|
|
14512
|
+
continue;
|
|
14513
|
+
}
|
|
14514
|
+
const localeValue = this.renderSchemaTranslationValue(
|
|
14515
|
+
theme,
|
|
14516
|
+
value,
|
|
14517
|
+
locale,
|
|
14518
|
+
localeConfigs
|
|
14519
|
+
);
|
|
14520
|
+
(0, import_lodash_es7.set)(result, `$locale.${locale}.${key}`, localeValue);
|
|
14521
|
+
}
|
|
14522
|
+
}
|
|
14506
14523
|
}
|
|
14507
14524
|
return result;
|
|
14508
14525
|
}
|
|
@@ -16384,18 +16401,11 @@ function bind58(_liquidSwell) {
|
|
|
16384
16401
|
}
|
|
16385
16402
|
|
|
16386
16403
|
// src/liquid/filters/shopify/img_url.ts
|
|
16387
|
-
function bind59(
|
|
16388
|
-
return function filterImgUrl(input, ...params) {
|
|
16389
|
-
|
|
16390
|
-
|
|
16391
|
-
|
|
16392
|
-
if (input.url) {
|
|
16393
|
-
url = input.url;
|
|
16394
|
-
} else {
|
|
16395
|
-
return "";
|
|
16396
|
-
}
|
|
16397
|
-
} else {
|
|
16398
|
-
url = String(input);
|
|
16404
|
+
function bind59(liquidSwell) {
|
|
16405
|
+
return async function filterImgUrl(input, ...params) {
|
|
16406
|
+
const url = await getImageUrlFromInput(input, liquidSwell);
|
|
16407
|
+
if (typeof url !== "string" || url === "") {
|
|
16408
|
+
return "";
|
|
16399
16409
|
}
|
|
16400
16410
|
const query = [];
|
|
16401
16411
|
params.forEach((param) => {
|
|
@@ -20195,6 +20205,7 @@ function getHtmlCache(env, cacheRules) {
|
|
|
20195
20205
|
scopeCustomCSS,
|
|
20196
20206
|
stringifyQueryParams,
|
|
20197
20207
|
systemFonts,
|
|
20198
|
-
toBase64
|
|
20208
|
+
toBase64,
|
|
20209
|
+
toBlockId
|
|
20199
20210
|
});
|
|
20200
20211
|
//# sourceMappingURL=index.cjs.map
|