@swell/apps-sdk 1.0.180 → 1.0.182
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 +113 -104
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +113 -104
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +115 -106
- package/dist/index.mjs.map +3 -3
- package/dist/src/compatibility/shopify-fonts.d.ts +1 -1
- package/dist/src/compatibility/shopify.d.ts +1 -1
- package/dist/src/liquid/filters/shopify/payment_button.d.ts +1 -1
- package/dist/src/resources.d.ts +2 -2
- package/dist/types/swell.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -915,7 +915,10 @@
|
|
|
915
915
|
}
|
|
916
916
|
return this._resolve().then(() => this.makeIterator());
|
|
917
917
|
}
|
|
918
|
-
makeIterator() {
|
|
918
|
+
async makeIterator() {
|
|
919
|
+
if (isLikePromise(this.results)) {
|
|
920
|
+
await this.results;
|
|
921
|
+
}
|
|
919
922
|
return (this.results || []).values();
|
|
920
923
|
}
|
|
921
924
|
_clone(newProps) {
|
|
@@ -3667,11 +3670,11 @@
|
|
|
3667
3670
|
);
|
|
3668
3671
|
}
|
|
3669
3672
|
function getCountryCodeFromLocale(locale) {
|
|
3670
|
-
const
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
return
|
|
3673
|
+
const [lang, country] = locale.split(/-|_/);
|
|
3674
|
+
if (country) {
|
|
3675
|
+
return country.toLowerCase();
|
|
3676
|
+
}
|
|
3677
|
+
return (LANG_TO_COUNTRY_CODES[lang] || "").toLowerCase();
|
|
3675
3678
|
}
|
|
3676
3679
|
function getCountryByCurrency(currencyCode) {
|
|
3677
3680
|
if (currencyCode in CURRENCY_COUNTRIES) {
|
|
@@ -5786,86 +5789,76 @@ ${formattedMessage}`;
|
|
|
5786
5789
|
}
|
|
5787
5790
|
function getAllSectionComponentTemplates(allSections) {
|
|
5788
5791
|
const list = [];
|
|
5792
|
+
const processFields = (fields, settings = {}) => {
|
|
5793
|
+
const result = {};
|
|
5794
|
+
for (const field of fields) {
|
|
5795
|
+
if (!field?.id) {
|
|
5796
|
+
continue;
|
|
5797
|
+
}
|
|
5798
|
+
const { id: fieldId, $locale } = field;
|
|
5799
|
+
result[fieldId] = schemaToEasyblocksValue(
|
|
5800
|
+
fields,
|
|
5801
|
+
fieldId,
|
|
5802
|
+
settings[fieldId]
|
|
5803
|
+
);
|
|
5804
|
+
if ($locale) {
|
|
5805
|
+
for (const [locale, localeValues] of Object.entries($locale)) {
|
|
5806
|
+
const defaultValue = localeValues?.default;
|
|
5807
|
+
if (defaultValue) {
|
|
5808
|
+
(0, import_lodash_es4.set)(result, `$locale.${locale}.${fieldId}`, defaultValue);
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
}
|
|
5813
|
+
return result;
|
|
5814
|
+
};
|
|
5789
5815
|
for (const section of allSections) {
|
|
5790
5816
|
if (section.presets) {
|
|
5791
|
-
|
|
5792
|
-
|
|
5817
|
+
for (let index = 0; index < section.presets.length; index++) {
|
|
5818
|
+
const preset = section.presets[index];
|
|
5819
|
+
const entry = {
|
|
5820
|
+
_id: `${section.id}__preset_${index}`,
|
|
5821
|
+
_component: section.id,
|
|
5822
|
+
custom_css: preset.settings?.["custom_css"] || "",
|
|
5823
|
+
...processFields(section.fields, preset.settings),
|
|
5824
|
+
// Process blocks inside the preset
|
|
5825
|
+
Blocks: (preset.blocks || []).map((block) => {
|
|
5826
|
+
const blockSchema = section.blocks?.find(
|
|
5827
|
+
({ type }) => type === block.type
|
|
5828
|
+
);
|
|
5829
|
+
if (!blockSchema) {
|
|
5830
|
+
return null;
|
|
5831
|
+
}
|
|
5832
|
+
return {
|
|
5833
|
+
_id: `Block__${section.id}__${block.type}__preset_${index}`,
|
|
5834
|
+
_component: `Block__${section.id}__${block.type}`,
|
|
5835
|
+
...processFields(blockSchema.fields, block.settings)
|
|
5836
|
+
};
|
|
5837
|
+
}).filter(Boolean)
|
|
5838
|
+
};
|
|
5839
|
+
list.push({
|
|
5793
5840
|
id: `${section.id}__preset_${index}`,
|
|
5794
|
-
entry
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
custom_css: preset.settings?.["custom_css"] || "",
|
|
5798
|
-
...(0, import_lodash_es4.reduce)(
|
|
5799
|
-
section.fields,
|
|
5800
|
-
(acc, field) => {
|
|
5801
|
-
if (field.id) {
|
|
5802
|
-
acc[field.id] = schemaToEasyblocksValue(
|
|
5803
|
-
section.fields,
|
|
5804
|
-
field.id,
|
|
5805
|
-
preset.settings?.[field.id]
|
|
5806
|
-
);
|
|
5807
|
-
}
|
|
5808
|
-
return acc;
|
|
5809
|
-
},
|
|
5810
|
-
{}
|
|
5811
|
-
),
|
|
5812
|
-
Blocks: preset.blocks?.reduce(
|
|
5813
|
-
(acc, block) => {
|
|
5814
|
-
const blockDef = section.blocks?.find(
|
|
5815
|
-
({ type }) => type === block.type
|
|
5816
|
-
);
|
|
5817
|
-
if (blockDef) {
|
|
5818
|
-
acc.push({
|
|
5819
|
-
_id: `Block__${section.id}__${block.type}__preset_${index}`,
|
|
5820
|
-
_component: `Block__${section.id}__${block.type}`,
|
|
5821
|
-
...(0, import_lodash_es4.reduce)(
|
|
5822
|
-
blockDef.fields,
|
|
5823
|
-
(acc2, blockField) => {
|
|
5824
|
-
if (blockField.id) {
|
|
5825
|
-
acc2[blockField.id] = schemaToEasyblocksValue(
|
|
5826
|
-
blockDef.fields,
|
|
5827
|
-
blockField.id,
|
|
5828
|
-
block.settings?.[blockField.id]
|
|
5829
|
-
);
|
|
5830
|
-
}
|
|
5831
|
-
return acc2;
|
|
5832
|
-
},
|
|
5833
|
-
{}
|
|
5834
|
-
)
|
|
5835
|
-
});
|
|
5836
|
-
}
|
|
5837
|
-
return acc;
|
|
5838
|
-
},
|
|
5839
|
-
[]
|
|
5840
|
-
)
|
|
5841
|
-
}
|
|
5842
|
-
}))
|
|
5843
|
-
);
|
|
5841
|
+
entry
|
|
5842
|
+
});
|
|
5843
|
+
}
|
|
5844
5844
|
}
|
|
5845
5845
|
if (section.blocks) {
|
|
5846
|
-
|
|
5847
|
-
|
|
5846
|
+
for (const block of section.blocks) {
|
|
5847
|
+
list.push({
|
|
5848
5848
|
id: `Block__${section.id}__${block.type}`,
|
|
5849
5849
|
entry: {
|
|
5850
5850
|
_id: `Block__${section.id}__${block.type}`,
|
|
5851
5851
|
_component: `Block__${section.id}__${block.type}`,
|
|
5852
|
-
...(
|
|
5852
|
+
...processFields(
|
|
5853
5853
|
block.fields,
|
|
5854
|
-
(acc,
|
|
5855
|
-
if (
|
|
5856
|
-
acc[field.id] = schemaToEasyblocksValue(
|
|
5857
|
-
block.fields,
|
|
5858
|
-
field.id,
|
|
5859
|
-
field.default
|
|
5860
|
-
);
|
|
5861
|
-
}
|
|
5854
|
+
block.fields.reduce((acc, f) => {
|
|
5855
|
+
if (f.id) acc[f.id] = f.default;
|
|
5862
5856
|
return acc;
|
|
5863
|
-
},
|
|
5864
|
-
{}
|
|
5857
|
+
}, {})
|
|
5865
5858
|
)
|
|
5866
5859
|
}
|
|
5867
|
-
})
|
|
5868
|
-
|
|
5860
|
+
});
|
|
5861
|
+
}
|
|
5869
5862
|
}
|
|
5870
5863
|
}
|
|
5871
5864
|
return list;
|
|
@@ -10253,6 +10246,9 @@ ${formattedMessage}`;
|
|
|
10253
10246
|
|
|
10254
10247
|
// src/compatibility/shopify-fonts.ts
|
|
10255
10248
|
function shopifyFontToThemeFront(shopifyFontSetting) {
|
|
10249
|
+
if (typeof shopifyFontSetting !== "string") {
|
|
10250
|
+
return null;
|
|
10251
|
+
}
|
|
10256
10252
|
const pos = shopifyFontSetting.lastIndexOf("_");
|
|
10257
10253
|
const familyId = shopifyFontSetting.substring(0, pos);
|
|
10258
10254
|
const variantId = shopifyFontSetting.substring(pos + 1);
|
|
@@ -11585,16 +11581,16 @@ ${formattedMessage}`;
|
|
|
11585
11581
|
if (!Array.isArray(blogs?.results)) {
|
|
11586
11582
|
return [];
|
|
11587
11583
|
}
|
|
11588
|
-
const
|
|
11589
|
-
(
|
|
11584
|
+
const set3 = blogs.results.reduce(
|
|
11585
|
+
(set4, blog) => {
|
|
11590
11586
|
for (const tag of blog.tags || []) {
|
|
11591
|
-
|
|
11587
|
+
set4.add(tag);
|
|
11592
11588
|
}
|
|
11593
|
-
return
|
|
11589
|
+
return set4;
|
|
11594
11590
|
},
|
|
11595
11591
|
/* @__PURE__ */ new Set()
|
|
11596
11592
|
);
|
|
11597
|
-
return Array.from(
|
|
11593
|
+
return Array.from(set3.values());
|
|
11598
11594
|
});
|
|
11599
11595
|
return new ShopifyResource({
|
|
11600
11596
|
all_tags: allTags,
|
|
@@ -11978,18 +11974,18 @@ ${formattedMessage}`;
|
|
|
11978
11974
|
if (!resolved) {
|
|
11979
11975
|
return [];
|
|
11980
11976
|
}
|
|
11981
|
-
const
|
|
11977
|
+
const set3 = /* @__PURE__ */ new Set();
|
|
11982
11978
|
await Promise.all(
|
|
11983
11979
|
resolved.results.map(async (product) => {
|
|
11984
11980
|
const tags2 = await Promise.resolve().then(() => product.tags);
|
|
11985
11981
|
if (Array.isArray(tags2)) {
|
|
11986
11982
|
for (const tag of tags2) {
|
|
11987
|
-
|
|
11983
|
+
set3.add(tag);
|
|
11988
11984
|
}
|
|
11989
11985
|
}
|
|
11990
11986
|
})
|
|
11991
11987
|
);
|
|
11992
|
-
return Array.from(
|
|
11988
|
+
return Array.from(set3.values());
|
|
11993
11989
|
}),
|
|
11994
11990
|
all_types: defer(async () => {
|
|
11995
11991
|
const products = await resolveProducts();
|
|
@@ -14339,26 +14335,32 @@ ${injects.join("\n")}<\/script>`;
|
|
|
14339
14335
|
if (!(0, import_lodash_es7.isObject)(schema)) {
|
|
14340
14336
|
return schema;
|
|
14341
14337
|
}
|
|
14342
|
-
const
|
|
14343
|
-
|
|
14344
|
-
localeCode
|
|
14345
|
-
|
|
14338
|
+
const locales = await theme.swell.storefront.locale.list();
|
|
14339
|
+
const localeCodes = /* @__PURE__ */ new Set([
|
|
14340
|
+
localeCode,
|
|
14341
|
+
...locales.map((locale) => locale.code)
|
|
14342
|
+
]);
|
|
14343
|
+
const localeConfigs = {};
|
|
14344
|
+
for (const locale of localeCodes) {
|
|
14345
|
+
localeConfigs[locale] = await this.getEditorLocaleConfig(theme, locale);
|
|
14346
|
+
}
|
|
14346
14347
|
return this.renderSchemaTranslationValue(
|
|
14347
14348
|
theme,
|
|
14348
14349
|
schema,
|
|
14349
14350
|
localeCode,
|
|
14350
|
-
|
|
14351
|
+
localeConfigs
|
|
14351
14352
|
);
|
|
14352
14353
|
}
|
|
14353
|
-
|
|
14354
|
+
renderSchemaTranslationValue(theme, schemaValue, localeCode, localeConfigs) {
|
|
14354
14355
|
switch (typeof schemaValue) {
|
|
14355
14356
|
case "string": {
|
|
14356
14357
|
if (schemaValue.startsWith("t:")) {
|
|
14358
|
+
const localeConfig = localeConfigs[localeCode];
|
|
14357
14359
|
const key = schemaValue.slice(2);
|
|
14358
14360
|
const keyParts = key?.split(".");
|
|
14359
14361
|
const keyName = keyParts.pop() || "";
|
|
14360
14362
|
const keyPath = keyParts.join(".");
|
|
14361
|
-
const langObject = (0, import_lodash_es7.get)(
|
|
14363
|
+
const langObject = (0, import_lodash_es7.get)(localeConfig, keyPath);
|
|
14362
14364
|
return langObject?.[keyName] ?? key;
|
|
14363
14365
|
}
|
|
14364
14366
|
break;
|
|
@@ -14368,11 +14370,11 @@ ${injects.join("\n")}<\/script>`;
|
|
|
14368
14370
|
const result = [];
|
|
14369
14371
|
for (const value of schemaValue) {
|
|
14370
14372
|
result.push(
|
|
14371
|
-
|
|
14373
|
+
this.renderSchemaTranslationValue(
|
|
14372
14374
|
theme,
|
|
14373
14375
|
value,
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
+
localeCode,
|
|
14377
|
+
localeConfigs
|
|
14376
14378
|
)
|
|
14377
14379
|
);
|
|
14378
14380
|
}
|
|
@@ -14381,12 +14383,26 @@ ${injects.join("\n")}<\/script>`;
|
|
|
14381
14383
|
if (schemaValue !== null) {
|
|
14382
14384
|
const result = { ...schemaValue };
|
|
14383
14385
|
for (const [key, value] of Object.entries(schemaValue)) {
|
|
14384
|
-
result[key] =
|
|
14386
|
+
result[key] = this.renderSchemaTranslationValue(
|
|
14385
14387
|
theme,
|
|
14386
14388
|
value,
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
+
localeCode,
|
|
14390
|
+
localeConfigs
|
|
14389
14391
|
);
|
|
14392
|
+
if (typeof value === "string" && value.startsWith("t:")) {
|
|
14393
|
+
for (const locale of Object.keys(localeConfigs)) {
|
|
14394
|
+
if (locale === localeCode) {
|
|
14395
|
+
continue;
|
|
14396
|
+
}
|
|
14397
|
+
const localeValue = this.renderSchemaTranslationValue(
|
|
14398
|
+
theme,
|
|
14399
|
+
value,
|
|
14400
|
+
locale,
|
|
14401
|
+
localeConfigs
|
|
14402
|
+
);
|
|
14403
|
+
(0, import_lodash_es7.set)(result, `$locale.${locale}.${key}`, localeValue);
|
|
14404
|
+
}
|
|
14405
|
+
}
|
|
14390
14406
|
}
|
|
14391
14407
|
return result;
|
|
14392
14408
|
}
|
|
@@ -16088,19 +16104,12 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16088
16104
|
// src/liquid/filters/locale_flag.ts
|
|
16089
16105
|
var import_country_flag_icons = __require("country-flag-icons");
|
|
16090
16106
|
var flags = __toESM(__require("country-flag-icons/string/1x1"), 1);
|
|
16091
|
-
function getCountryCode(localCode) {
|
|
16092
|
-
if (localCode.includes("-")) {
|
|
16093
|
-
return localCode.split("-")[1].toUpperCase();
|
|
16094
|
-
} else {
|
|
16095
|
-
return localCode.toUpperCase();
|
|
16096
|
-
}
|
|
16097
|
-
}
|
|
16098
16107
|
function bind46(_liquidSwell) {
|
|
16099
16108
|
return (localeCode) => {
|
|
16100
16109
|
if (typeof localeCode !== "string") {
|
|
16101
16110
|
return flags.US;
|
|
16102
16111
|
}
|
|
16103
|
-
const countryCode =
|
|
16112
|
+
const countryCode = getCountryCodeFromLocale(localeCode).toUpperCase();
|
|
16104
16113
|
return (0, import_country_flag_icons.hasFlag)(countryCode) ? flags[countryCode] : flags.US;
|
|
16105
16114
|
};
|
|
16106
16115
|
}
|
|
@@ -16308,7 +16317,7 @@ ${injects.join("\n")}<\/script>`;
|
|
|
16308
16317
|
// src/liquid/filters/shopify/payment_button.ts
|
|
16309
16318
|
function bind60(_liquidSwell) {
|
|
16310
16319
|
return (form) => {
|
|
16311
|
-
return
|
|
16320
|
+
return `<button style="display: block; visibility: hidden;"></button>`;
|
|
16312
16321
|
};
|
|
16313
16322
|
}
|
|
16314
16323
|
|
|
@@ -18822,7 +18831,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
18822
18831
|
let blocks = settings.section.blocks?.filter(
|
|
18823
18832
|
(block) => block.disabled !== true
|
|
18824
18833
|
);
|
|
18825
|
-
blocks = blocks?.map((block) => ({
|
|
18834
|
+
blocks = blocks?.filter((block) => Boolean(block.type)).map((block) => ({
|
|
18826
18835
|
...block,
|
|
18827
18836
|
...getBlockAttributes(theme, block),
|
|
18828
18837
|
settings: resolveThemeSettings(
|