@swell/apps-sdk 1.0.148 → 1.0.149
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 +726 -226
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +723 -225
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +637 -138
- package/dist/index.mjs.map +4 -4
- package/dist/src/compatibility/drops/all_products.d.ts +10 -0
- package/dist/src/compatibility/drops/articles.d.ts +10 -0
- package/dist/src/compatibility/drops/blogs.d.ts +10 -0
- package/dist/src/compatibility/drops/collections.d.ts +9 -4
- package/dist/src/compatibility/drops/images.d.ts +10 -0
- package/dist/src/compatibility/drops/pages.d.ts +18 -0
- package/dist/src/compatibility/drops/robots-rule.d.ts +9 -0
- package/dist/src/compatibility/shopify-objects/image.d.ts +1 -2
- package/dist/src/compatibility/shopify-objects/media.d.ts +1 -2
- package/dist/src/compatibility/shopify.d.ts +1 -2
- package/dist/src/content.d.ts +8 -8
- package/dist/src/globals.d.ts +7 -0
- package/dist/src/liquid/drops/render.d.ts +10 -0
- package/dist/src/liquid/utils.d.ts +2 -1
- package/dist/src/theme.d.ts +6 -4
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/types/shopify.d.ts +12 -0
- package/dist/types/swell.d.ts +16 -1
- package/package.json +1 -1
- package/dist/src/compatibility/drops/render.d.ts +0 -6
package/dist/index.cjs
CHANGED
|
@@ -48,7 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
ShopifyCart: () => ShopifyCart,
|
|
49
49
|
ShopifyCollection: () => ShopifyCollection,
|
|
50
50
|
ShopifyCollections: () => ShopifyCollections,
|
|
51
|
-
ShopifyCompatibility: () =>
|
|
51
|
+
ShopifyCompatibility: () => ShopifyCompatibility2,
|
|
52
52
|
ShopifyCustomer: () => ShopifyCustomer,
|
|
53
53
|
ShopifyFont: () => ShopifyFont,
|
|
54
54
|
ShopifyForm: () => ShopifyForm,
|
|
@@ -119,6 +119,7 @@ __export(index_exports, {
|
|
|
119
119
|
getPage: () => getPage,
|
|
120
120
|
getPageSections: () => getPageSections,
|
|
121
121
|
getSectionGroupProp: () => getSectionGroupProp,
|
|
122
|
+
getSectionLocation: () => getSectionLocation,
|
|
122
123
|
getSectionSettingsFromProps: () => getSectionSettingsFromProps,
|
|
123
124
|
getThemeSettingsFromProps: () => getThemeSettingsFromProps,
|
|
124
125
|
isArray: () => isArray2,
|
|
@@ -459,7 +460,8 @@ var ForloopDrop = class extends import_liquidjs.Drop {
|
|
|
459
460
|
last;
|
|
460
461
|
rindex;
|
|
461
462
|
rindex0;
|
|
462
|
-
|
|
463
|
+
parentloop;
|
|
464
|
+
constructor(length, collection, variable, parent) {
|
|
463
465
|
super();
|
|
464
466
|
this.length = length;
|
|
465
467
|
this.name = `${variable}-${collection}`;
|
|
@@ -467,9 +469,10 @@ var ForloopDrop = class extends import_liquidjs.Drop {
|
|
|
467
469
|
this.index = 1;
|
|
468
470
|
this.index0 = 0;
|
|
469
471
|
this.first = true;
|
|
470
|
-
this.last =
|
|
472
|
+
this.last = length <= 0;
|
|
471
473
|
this.rindex = length;
|
|
472
474
|
this.rindex0 = length - 1;
|
|
475
|
+
this.parentloop = parent ?? null;
|
|
473
476
|
}
|
|
474
477
|
next() {
|
|
475
478
|
this.i += 1;
|
|
@@ -676,6 +679,8 @@ var StorefrontResource = class {
|
|
|
676
679
|
switch (prop) {
|
|
677
680
|
// Ignore liquid prop checks
|
|
678
681
|
case "toLiquid":
|
|
682
|
+
return typeof instance.toLiquid === "function" ? instance.toLiquid : void 0;
|
|
683
|
+
// Ignore liquid prop checks
|
|
679
684
|
case "next":
|
|
680
685
|
return;
|
|
681
686
|
// Indicate props are thenable
|
|
@@ -6668,6 +6673,7 @@ function getSectionSettingsFromProps(props, sectionSchema) {
|
|
|
6668
6673
|
}
|
|
6669
6674
|
),
|
|
6670
6675
|
id: sectionSchema.id,
|
|
6676
|
+
type: sectionSchema.id,
|
|
6671
6677
|
blocks: props.Blocks?.filter(
|
|
6672
6678
|
(propBlock) => Boolean(propBlock.props.compiled?._component)
|
|
6673
6679
|
).map((propBlock) => {
|
|
@@ -6688,7 +6694,8 @@ function getSectionSettingsFromProps(props, sectionSchema) {
|
|
|
6688
6694
|
{ $locale: blockProps.$locale }
|
|
6689
6695
|
) || {}
|
|
6690
6696
|
};
|
|
6691
|
-
})
|
|
6697
|
+
}),
|
|
6698
|
+
location: getSectionLocation(sectionSchema.id)
|
|
6692
6699
|
};
|
|
6693
6700
|
}
|
|
6694
6701
|
function toEasyblocksFieldId(fieldId) {
|
|
@@ -6945,7 +6952,8 @@ async function getLayoutSectionGroups(allSections, renderTemplateSchema) {
|
|
|
6945
6952
|
async function getPageSections(sectionGroup, getSchema) {
|
|
6946
6953
|
const order = Array.isArray(sectionGroup?.order) && sectionGroup.order.length > 0 ? sectionGroup.order : Object.keys(sectionGroup?.sections || {});
|
|
6947
6954
|
const pageSections = [];
|
|
6948
|
-
for (
|
|
6955
|
+
for (let i = 0; i < order.length; ++i) {
|
|
6956
|
+
const key = order[i];
|
|
6949
6957
|
const section = sectionGroup.sections?.[key];
|
|
6950
6958
|
if (!section) {
|
|
6951
6959
|
continue;
|
|
@@ -6967,7 +6975,10 @@ async function getPageSections(sectionGroup, getSchema) {
|
|
|
6967
6975
|
section: {
|
|
6968
6976
|
id,
|
|
6969
6977
|
...section,
|
|
6970
|
-
blocks
|
|
6978
|
+
blocks,
|
|
6979
|
+
index0: i,
|
|
6980
|
+
index: i + 1,
|
|
6981
|
+
location: getSectionLocation(section.type)
|
|
6971
6982
|
}
|
|
6972
6983
|
};
|
|
6973
6984
|
pageSections.push({
|
|
@@ -7211,6 +7222,15 @@ function extractSettingsFromForm(form, currentSettings) {
|
|
|
7211
7222
|
(0, import_lodash_es3.cloneDeep)(currentSettings)
|
|
7212
7223
|
);
|
|
7213
7224
|
}
|
|
7225
|
+
function getSectionLocation(sectionType) {
|
|
7226
|
+
switch (sectionType) {
|
|
7227
|
+
case "header":
|
|
7228
|
+
case "footer":
|
|
7229
|
+
return sectionType;
|
|
7230
|
+
default:
|
|
7231
|
+
return sectionType ? `custom.${sectionType}` : "template";
|
|
7232
|
+
}
|
|
7233
|
+
}
|
|
7214
7234
|
var SECTION_GROUP_CONTENT = "ContentSections";
|
|
7215
7235
|
function getSectionGroupProp(sectionId) {
|
|
7216
7236
|
return `SectionGroup_${sectionId}`;
|
|
@@ -8120,19 +8140,19 @@ function getContentModel(swell, name) {
|
|
|
8120
8140
|
})
|
|
8121
8141
|
);
|
|
8122
8142
|
}
|
|
8123
|
-
|
|
8143
|
+
function getContentList(swell, type, query) {
|
|
8124
8144
|
return new SwellStorefrontCollection(swell, `content/${type}`, query);
|
|
8125
8145
|
}
|
|
8126
|
-
|
|
8146
|
+
function getContentEntry(swell, type, id, query) {
|
|
8127
8147
|
return new SwellStorefrontRecord(swell, `content/${type}`, id, query);
|
|
8128
8148
|
}
|
|
8129
|
-
|
|
8149
|
+
function getPage(swell, id, query) {
|
|
8130
8150
|
return getContentEntry(swell, "pages", id, query);
|
|
8131
8151
|
}
|
|
8132
|
-
|
|
8152
|
+
function getBlogs(swell, query) {
|
|
8133
8153
|
return getContentList(swell, "blogs", query);
|
|
8134
8154
|
}
|
|
8135
|
-
|
|
8155
|
+
function getBlog(swell, id, query) {
|
|
8136
8156
|
return getContentEntry(swell, "blogs", id, query);
|
|
8137
8157
|
}
|
|
8138
8158
|
|
|
@@ -8942,11 +8962,11 @@ function getRandomId() {
|
|
|
8942
8962
|
}
|
|
8943
8963
|
|
|
8944
8964
|
// src/menus.ts
|
|
8945
|
-
var
|
|
8965
|
+
var import_lodash_es14 = require("lodash-es");
|
|
8946
8966
|
|
|
8947
8967
|
// src/theme.ts
|
|
8948
8968
|
var import_json56 = __toESM(require("json5"), 1);
|
|
8949
|
-
var
|
|
8969
|
+
var import_lodash_es13 = require("lodash-es");
|
|
8950
8970
|
|
|
8951
8971
|
// src/compatibility/shopify.ts
|
|
8952
8972
|
var import_lodash_es7 = require("lodash-es");
|
|
@@ -14130,7 +14150,7 @@ __export(shopify_objects_exports, {
|
|
|
14130
14150
|
});
|
|
14131
14151
|
|
|
14132
14152
|
// src/compatibility/shopify-objects/image.ts
|
|
14133
|
-
function ShopifyImage(
|
|
14153
|
+
function ShopifyImage(image, options = {}, product, variant) {
|
|
14134
14154
|
if (image instanceof ShopifyResource) {
|
|
14135
14155
|
return image.clone();
|
|
14136
14156
|
}
|
|
@@ -14192,7 +14212,7 @@ function ShopifyArticle(instance, blog, blogCategory) {
|
|
|
14192
14212
|
id: defer(() => blog.id),
|
|
14193
14213
|
image: deferWith(
|
|
14194
14214
|
blog,
|
|
14195
|
-
(blog2) => blog2.image ? ShopifyImage(
|
|
14215
|
+
(blog2) => blog2.image ? ShopifyImage(blog2.image) : void 0
|
|
14196
14216
|
),
|
|
14197
14217
|
metafields: {},
|
|
14198
14218
|
published_at: deferWith(
|
|
@@ -14282,7 +14302,7 @@ function ShopifyBlog(instance, blogCategory) {
|
|
|
14282
14302
|
}
|
|
14283
14303
|
|
|
14284
14304
|
// src/compatibility/shopify-objects/media.ts
|
|
14285
|
-
function ShopifyMedia(
|
|
14305
|
+
function ShopifyMedia(image, options) {
|
|
14286
14306
|
if (image instanceof ShopifyResource) {
|
|
14287
14307
|
return image.clone();
|
|
14288
14308
|
}
|
|
@@ -14291,7 +14311,7 @@ function ShopifyMedia(instance, image, options) {
|
|
|
14291
14311
|
id: image.id || image.file?.id,
|
|
14292
14312
|
media_type: options?.media_type ?? "image",
|
|
14293
14313
|
position: options?.position,
|
|
14294
|
-
preview_image: ShopifyImage(
|
|
14314
|
+
preview_image: ShopifyImage(image)
|
|
14295
14315
|
});
|
|
14296
14316
|
}
|
|
14297
14317
|
|
|
@@ -14319,19 +14339,19 @@ function ShopifyVariant(instance, variant, productIn, depth = 0) {
|
|
|
14319
14339
|
[product, variant],
|
|
14320
14340
|
(product2, variant2) => {
|
|
14321
14341
|
const image = variant2.images?.[0] || product2.images?.[0];
|
|
14322
|
-
return image ? ShopifyImage(
|
|
14342
|
+
return image ? ShopifyImage(image, {}, product2, variant2) : void 0;
|
|
14323
14343
|
}
|
|
14324
14344
|
),
|
|
14325
14345
|
featured_media: deferWith([product, variant], (product2, variant2) => {
|
|
14326
14346
|
const image = variant2.images?.[0] || product2.images?.[0];
|
|
14327
|
-
return image ? ShopifyMedia(
|
|
14347
|
+
return image ? ShopifyMedia(image, { media_type: "image" }) : void 0;
|
|
14328
14348
|
}),
|
|
14329
14349
|
id: defer(() => variant.id),
|
|
14330
14350
|
image: deferWith(
|
|
14331
14351
|
[product, variant],
|
|
14332
14352
|
(product2, variant2) => {
|
|
14333
14353
|
const image = variant2.images?.[0] || product2.images?.[0];
|
|
14334
|
-
return image ? ShopifyImage(
|
|
14354
|
+
return image ? ShopifyImage(image, {}, product2, variant2) : void 0;
|
|
14335
14355
|
}
|
|
14336
14356
|
),
|
|
14337
14357
|
incoming: false,
|
|
@@ -14483,11 +14503,11 @@ function ShopifyProduct(instance, product, depth = 0) {
|
|
|
14483
14503
|
description: defer(() => product.description),
|
|
14484
14504
|
featured_image: deferWith(product, (product2) => {
|
|
14485
14505
|
const image = product2.images?.[0];
|
|
14486
|
-
return image ? ShopifyImage(
|
|
14506
|
+
return image ? ShopifyImage(image, {}, product2) : void 0;
|
|
14487
14507
|
}),
|
|
14488
14508
|
featured_media: deferWith(product, (product2) => {
|
|
14489
14509
|
const image = product2.images?.[0];
|
|
14490
|
-
return image ? ShopifyMedia(
|
|
14510
|
+
return image ? ShopifyMedia(image) : void 0;
|
|
14491
14511
|
}),
|
|
14492
14512
|
// not used
|
|
14493
14513
|
first_available_variant: deferWith(product, (product2) => {
|
|
@@ -14507,7 +14527,7 @@ function ShopifyProduct(instance, product, depth = 0) {
|
|
|
14507
14527
|
return [];
|
|
14508
14528
|
}
|
|
14509
14529
|
return product2.images.map(
|
|
14510
|
-
(image, index) => ShopifyImage(
|
|
14530
|
+
(image, index) => ShopifyImage(image, { position: index + 1 }, product2)
|
|
14511
14531
|
);
|
|
14512
14532
|
}),
|
|
14513
14533
|
media: deferWith(product, (product2) => {
|
|
@@ -14515,7 +14535,7 @@ function ShopifyProduct(instance, product, depth = 0) {
|
|
|
14515
14535
|
return [];
|
|
14516
14536
|
}
|
|
14517
14537
|
return product2.images.map(
|
|
14518
|
-
(image, index) => ShopifyMedia(
|
|
14538
|
+
(image, index) => ShopifyMedia(image, {
|
|
14519
14539
|
media_type: "image",
|
|
14520
14540
|
position: index + 1
|
|
14521
14541
|
})
|
|
@@ -14745,7 +14765,7 @@ function ShopifyLineItem(instance, item, cart, options = {}) {
|
|
|
14745
14765
|
[item.product, item.variant],
|
|
14746
14766
|
(product, variant) => {
|
|
14747
14767
|
const image = product?.images?.[0];
|
|
14748
|
-
return image ? ShopifyImage(
|
|
14768
|
+
return image ? ShopifyImage(image, {}, product, variant) : void 0;
|
|
14749
14769
|
}
|
|
14750
14770
|
),
|
|
14751
14771
|
item_components: (item.bundle_items ?? []).map(
|
|
@@ -15151,10 +15171,7 @@ function ShopifyCollection(instance, category) {
|
|
|
15151
15171
|
(category2) => convertToShopifySorting(category2.sort_options?.[0].value ?? "")
|
|
15152
15172
|
),
|
|
15153
15173
|
description: defer(() => category.description),
|
|
15154
|
-
featured_image: deferWith(
|
|
15155
|
-
category,
|
|
15156
|
-
(category2) => getFirstImage(instance, category2)
|
|
15157
|
-
),
|
|
15174
|
+
featured_image: deferWith(category, (category2) => getFirstImage(category2)),
|
|
15158
15175
|
filters: deferWith(
|
|
15159
15176
|
category,
|
|
15160
15177
|
(category2) => (category2?.filter_options ?? []).map(
|
|
@@ -15163,7 +15180,7 @@ function ShopifyCollection(instance, category) {
|
|
|
15163
15180
|
),
|
|
15164
15181
|
handle: defer(() => category.slug),
|
|
15165
15182
|
id: defer(() => category.id),
|
|
15166
|
-
image: deferWith(category, (category2) => getFirstImage(
|
|
15183
|
+
image: deferWith(category, (category2) => getFirstImage(category2)),
|
|
15167
15184
|
metafields: {},
|
|
15168
15185
|
next_product: void 0,
|
|
15169
15186
|
previous_product: void 0,
|
|
@@ -15183,9 +15200,9 @@ function ShopifyCollection(instance, category) {
|
|
|
15183
15200
|
url: deferWith(category, (category2) => `/collections/${category2.slug}`)
|
|
15184
15201
|
});
|
|
15185
15202
|
}
|
|
15186
|
-
function getFirstImage(
|
|
15203
|
+
function getFirstImage(category) {
|
|
15187
15204
|
const image = category.images?.[0];
|
|
15188
|
-
return image ? ShopifyImage(
|
|
15205
|
+
return image ? ShopifyImage(image) : void 0;
|
|
15189
15206
|
}
|
|
15190
15207
|
function convertToShopifySorting(value) {
|
|
15191
15208
|
switch (value) {
|
|
@@ -16138,38 +16155,72 @@ function ShopifyShop(instance, store) {
|
|
|
16138
16155
|
});
|
|
16139
16156
|
}
|
|
16140
16157
|
|
|
16141
|
-
// src/compatibility/drops/
|
|
16158
|
+
// src/compatibility/drops/all_products.ts
|
|
16142
16159
|
var import_liquidjs3 = require("liquidjs");
|
|
16143
|
-
var
|
|
16160
|
+
var AllProductsDrop = class extends import_liquidjs3.Drop {
|
|
16161
|
+
#instance;
|
|
16144
16162
|
#map;
|
|
16145
|
-
constructor(
|
|
16163
|
+
constructor(instance) {
|
|
16146
16164
|
super();
|
|
16147
|
-
|
|
16165
|
+
this.#instance = instance;
|
|
16166
|
+
this.#map = /* @__PURE__ */ new Map();
|
|
16167
|
+
}
|
|
16168
|
+
liquidMethodMissing(key) {
|
|
16169
|
+
switch (typeof key) {
|
|
16170
|
+
case "string": {
|
|
16171
|
+
return this.getProduct(key);
|
|
16172
|
+
}
|
|
16148
16173
|
case "object": {
|
|
16149
|
-
if (
|
|
16150
|
-
|
|
16151
|
-
|
|
16174
|
+
if (key !== null) {
|
|
16175
|
+
const obj = key;
|
|
16176
|
+
const id = obj.handle || obj.id || obj._id;
|
|
16177
|
+
if (isLikePromise(id)) {
|
|
16178
|
+
return id.then((id2) => this.getProduct(id2));
|
|
16179
|
+
}
|
|
16180
|
+
return this.getProduct(id);
|
|
16152
16181
|
}
|
|
16153
|
-
this.#map = new Map(
|
|
16154
|
-
map instanceof Map ? map : Object.entries(map)
|
|
16155
|
-
);
|
|
16156
16182
|
break;
|
|
16157
16183
|
}
|
|
16158
16184
|
default:
|
|
16159
|
-
this.#map = /* @__PURE__ */ new Map();
|
|
16160
16185
|
break;
|
|
16161
16186
|
}
|
|
16162
16187
|
}
|
|
16188
|
+
getProduct(slug) {
|
|
16189
|
+
let resource = this.#map.get(slug);
|
|
16190
|
+
if (resource === void 0 && this.#map.size < 20) {
|
|
16191
|
+
resource = ShopifyProduct(
|
|
16192
|
+
this.#instance,
|
|
16193
|
+
new SwellStorefrontRecord(this.#instance.swell, "products", slug)
|
|
16194
|
+
);
|
|
16195
|
+
this.#map.set(slug, resource);
|
|
16196
|
+
}
|
|
16197
|
+
return resource ?? null;
|
|
16198
|
+
}
|
|
16199
|
+
};
|
|
16200
|
+
|
|
16201
|
+
// src/compatibility/drops/articles.ts
|
|
16202
|
+
var import_liquidjs4 = require("liquidjs");
|
|
16203
|
+
var ArticlesDrop = class extends import_liquidjs4.Drop {
|
|
16204
|
+
#instance;
|
|
16205
|
+
#map;
|
|
16206
|
+
constructor(instance) {
|
|
16207
|
+
super();
|
|
16208
|
+
this.#instance = instance;
|
|
16209
|
+
this.#map = /* @__PURE__ */ new Map();
|
|
16210
|
+
}
|
|
16163
16211
|
liquidMethodMissing(key) {
|
|
16164
16212
|
switch (typeof key) {
|
|
16165
|
-
case "string":
|
|
16166
|
-
return this
|
|
16213
|
+
case "string": {
|
|
16214
|
+
return this.getArticle(key);
|
|
16215
|
+
}
|
|
16167
16216
|
case "object": {
|
|
16168
|
-
if (key !== null
|
|
16169
|
-
const
|
|
16170
|
-
|
|
16171
|
-
|
|
16217
|
+
if (key !== null) {
|
|
16218
|
+
const obj = key;
|
|
16219
|
+
const id = obj.handle || obj.id || obj._id;
|
|
16220
|
+
if (isLikePromise(id)) {
|
|
16221
|
+
return id.then((id2) => this.getArticle(id2));
|
|
16172
16222
|
}
|
|
16223
|
+
return this.getArticle(id);
|
|
16173
16224
|
}
|
|
16174
16225
|
break;
|
|
16175
16226
|
}
|
|
@@ -16177,13 +16228,71 @@ var ObjectHandlesDrop = class extends import_liquidjs3.Drop {
|
|
|
16177
16228
|
break;
|
|
16178
16229
|
}
|
|
16179
16230
|
}
|
|
16231
|
+
getArticle(slug) {
|
|
16232
|
+
let resource = this.#map.get(slug);
|
|
16233
|
+
if (resource === void 0) {
|
|
16234
|
+
resource = ShopifyArticle(
|
|
16235
|
+
this.#instance,
|
|
16236
|
+
new SwellStorefrontRecord(this.#instance.swell, "content/blogs", slug)
|
|
16237
|
+
);
|
|
16238
|
+
this.#map.set(slug, resource);
|
|
16239
|
+
}
|
|
16240
|
+
return resource;
|
|
16241
|
+
}
|
|
16242
|
+
};
|
|
16243
|
+
|
|
16244
|
+
// src/compatibility/drops/blogs.ts
|
|
16245
|
+
var import_liquidjs5 = require("liquidjs");
|
|
16246
|
+
var BlogsDrop = class extends import_liquidjs5.Drop {
|
|
16247
|
+
#instance;
|
|
16248
|
+
#map;
|
|
16249
|
+
constructor(instance) {
|
|
16250
|
+
super();
|
|
16251
|
+
this.#instance = instance;
|
|
16252
|
+
this.#map = /* @__PURE__ */ new Map();
|
|
16253
|
+
}
|
|
16254
|
+
liquidMethodMissing(key) {
|
|
16255
|
+
switch (typeof key) {
|
|
16256
|
+
case "string": {
|
|
16257
|
+
return this.getBlog(key);
|
|
16258
|
+
}
|
|
16259
|
+
case "object": {
|
|
16260
|
+
if (key !== null) {
|
|
16261
|
+
const obj = key;
|
|
16262
|
+
const id = obj.handle || obj.id || obj._id;
|
|
16263
|
+
if (isLikePromise(id)) {
|
|
16264
|
+
return id.then((id2) => this.getBlog(id2));
|
|
16265
|
+
}
|
|
16266
|
+
return this.getBlog(id);
|
|
16267
|
+
}
|
|
16268
|
+
break;
|
|
16269
|
+
}
|
|
16270
|
+
default:
|
|
16271
|
+
break;
|
|
16272
|
+
}
|
|
16273
|
+
}
|
|
16274
|
+
getBlog(slug) {
|
|
16275
|
+
let resource = this.#map.get(slug);
|
|
16276
|
+
if (resource === void 0) {
|
|
16277
|
+
resource = ShopifyBlog(
|
|
16278
|
+
this.#instance,
|
|
16279
|
+
new SwellStorefrontRecord(
|
|
16280
|
+
this.#instance.swell,
|
|
16281
|
+
"content/blog-categories",
|
|
16282
|
+
slug
|
|
16283
|
+
)
|
|
16284
|
+
);
|
|
16285
|
+
this.#map.set(slug, resource);
|
|
16286
|
+
}
|
|
16287
|
+
return resource;
|
|
16288
|
+
}
|
|
16180
16289
|
};
|
|
16181
16290
|
|
|
16182
16291
|
// src/compatibility/drops/collections.ts
|
|
16183
|
-
var
|
|
16184
|
-
var AllCategoryResource = class extends
|
|
16292
|
+
var import_liquidjs6 = require("liquidjs");
|
|
16293
|
+
var AllCategoryResource = class extends StorefrontResource {
|
|
16185
16294
|
constructor(instance) {
|
|
16186
|
-
super(
|
|
16295
|
+
super(() => {
|
|
16187
16296
|
const category = {
|
|
16188
16297
|
id: "all",
|
|
16189
16298
|
slug: "all",
|
|
@@ -16194,15 +16303,12 @@ var AllCategoryResource = class extends SwellStorefrontRecord {
|
|
|
16194
16303
|
});
|
|
16195
16304
|
}
|
|
16196
16305
|
};
|
|
16197
|
-
var CollectionsDrop = class extends
|
|
16306
|
+
var CollectionsDrop = class extends import_liquidjs6.Drop {
|
|
16198
16307
|
#instance;
|
|
16199
|
-
#categories;
|
|
16200
|
-
#size;
|
|
16201
16308
|
#map;
|
|
16202
16309
|
constructor(instance) {
|
|
16203
16310
|
super();
|
|
16204
16311
|
this.#instance = instance;
|
|
16205
|
-
this.#size = Number.NaN;
|
|
16206
16312
|
this.#map = /* @__PURE__ */ new Map();
|
|
16207
16313
|
}
|
|
16208
16314
|
liquidMethodMissing(key) {
|
|
@@ -16247,36 +16353,32 @@ var CollectionsDrop = class extends import_liquidjs4.Drop {
|
|
|
16247
16353
|
}
|
|
16248
16354
|
return resource;
|
|
16249
16355
|
}
|
|
16250
|
-
|
|
16251
|
-
|
|
16252
|
-
|
|
16253
|
-
|
|
16254
|
-
|
|
16255
|
-
|
|
16256
|
-
|
|
16257
|
-
|
|
16258
|
-
|
|
16259
|
-
|
|
16260
|
-
|
|
16261
|
-
|
|
16356
|
+
};
|
|
16357
|
+
var Collections = class extends SwellStorefrontCollection {
|
|
16358
|
+
#drop;
|
|
16359
|
+
constructor(instance) {
|
|
16360
|
+
super(instance.swell, "categories", {}, async () => {
|
|
16361
|
+
const response = await this._defaultGetter().call(this);
|
|
16362
|
+
if (!response) {
|
|
16363
|
+
return null;
|
|
16364
|
+
}
|
|
16365
|
+
return {
|
|
16366
|
+
...response,
|
|
16367
|
+
page_count: response.page_count || 0,
|
|
16368
|
+
results: response.results.map(
|
|
16369
|
+
(item) => ShopifyCollection(instance, item)
|
|
16370
|
+
)
|
|
16371
|
+
};
|
|
16372
|
+
});
|
|
16373
|
+
this.#drop = new CollectionsDrop(instance);
|
|
16262
16374
|
}
|
|
16263
|
-
|
|
16264
|
-
|
|
16265
|
-
this.#categories = await this.#instance.swell.storefront.categories.list().then((res) => {
|
|
16266
|
-
return res.results.map(
|
|
16267
|
-
(category) => ShopifyCollection(
|
|
16268
|
-
this.#instance,
|
|
16269
|
-
new SwellStorefrontCategory(this.#instance, category.slug)
|
|
16270
|
-
)
|
|
16271
|
-
);
|
|
16272
|
-
});
|
|
16273
|
-
}
|
|
16274
|
-
return this.#categories.values();
|
|
16375
|
+
toLiquid() {
|
|
16376
|
+
return this.#drop;
|
|
16275
16377
|
}
|
|
16276
16378
|
};
|
|
16277
|
-
var SwellStorefrontCategory = class extends
|
|
16379
|
+
var SwellStorefrontCategory = class extends StorefrontResource {
|
|
16278
16380
|
constructor(instance, id, query) {
|
|
16279
|
-
super(
|
|
16381
|
+
super(async () => {
|
|
16280
16382
|
const category = new SwellStorefrontRecord(
|
|
16281
16383
|
instance.swell,
|
|
16282
16384
|
"categories",
|
|
@@ -16317,8 +16419,168 @@ var SwellStorefrontProducts = class extends SwellStorefrontCollection {
|
|
|
16317
16419
|
}
|
|
16318
16420
|
};
|
|
16319
16421
|
|
|
16422
|
+
// src/compatibility/drops/images.ts
|
|
16423
|
+
var import_liquidjs7 = require("liquidjs");
|
|
16424
|
+
var ImagesDrop = class extends import_liquidjs7.Drop {
|
|
16425
|
+
#instance;
|
|
16426
|
+
#map;
|
|
16427
|
+
constructor(instance) {
|
|
16428
|
+
super();
|
|
16429
|
+
this.#instance = instance;
|
|
16430
|
+
this.#map = /* @__PURE__ */ new Map();
|
|
16431
|
+
}
|
|
16432
|
+
liquidMethodMissing(key) {
|
|
16433
|
+
switch (typeof key) {
|
|
16434
|
+
case "string": {
|
|
16435
|
+
return this.getImage(key);
|
|
16436
|
+
}
|
|
16437
|
+
case "object": {
|
|
16438
|
+
if (key !== null) {
|
|
16439
|
+
const obj = key;
|
|
16440
|
+
const id = obj.handle || obj.id || obj._id;
|
|
16441
|
+
if (isLikePromise(id)) {
|
|
16442
|
+
return id.then((id2) => this.getImage(id2));
|
|
16443
|
+
}
|
|
16444
|
+
return this.getImage(id);
|
|
16445
|
+
}
|
|
16446
|
+
break;
|
|
16447
|
+
}
|
|
16448
|
+
default:
|
|
16449
|
+
break;
|
|
16450
|
+
}
|
|
16451
|
+
}
|
|
16452
|
+
getImage(name) {
|
|
16453
|
+
let resource = this.#map.get(name);
|
|
16454
|
+
if (resource === void 0) {
|
|
16455
|
+
resource = ShopifyImage(new SwellImage(this.#instance.swell, name));
|
|
16456
|
+
this.#map.set(name, resource);
|
|
16457
|
+
}
|
|
16458
|
+
return resource;
|
|
16459
|
+
}
|
|
16460
|
+
};
|
|
16461
|
+
var SwellImage = class extends StorefrontResource {
|
|
16462
|
+
constructor(swell, name) {
|
|
16463
|
+
super(async () => {
|
|
16464
|
+
const files = await swell.get("/:files", {
|
|
16465
|
+
private: { $ne: true },
|
|
16466
|
+
content_type: { $regex: "^image/" },
|
|
16467
|
+
filename: name
|
|
16468
|
+
});
|
|
16469
|
+
const file = files?.results[0] ?? null;
|
|
16470
|
+
if (file === null) {
|
|
16471
|
+
return null;
|
|
16472
|
+
}
|
|
16473
|
+
return { file };
|
|
16474
|
+
});
|
|
16475
|
+
}
|
|
16476
|
+
};
|
|
16477
|
+
|
|
16478
|
+
// src/compatibility/drops/object-handles.ts
|
|
16479
|
+
var import_liquidjs8 = require("liquidjs");
|
|
16480
|
+
var ObjectHandlesDrop = class extends import_liquidjs8.Drop {
|
|
16481
|
+
#map;
|
|
16482
|
+
constructor(map) {
|
|
16483
|
+
super();
|
|
16484
|
+
switch (typeof map) {
|
|
16485
|
+
case "object": {
|
|
16486
|
+
if (map === null) {
|
|
16487
|
+
this.#map = /* @__PURE__ */ new Map();
|
|
16488
|
+
break;
|
|
16489
|
+
}
|
|
16490
|
+
this.#map = new Map(
|
|
16491
|
+
map instanceof Map ? map : Object.entries(map)
|
|
16492
|
+
);
|
|
16493
|
+
break;
|
|
16494
|
+
}
|
|
16495
|
+
default:
|
|
16496
|
+
this.#map = /* @__PURE__ */ new Map();
|
|
16497
|
+
break;
|
|
16498
|
+
}
|
|
16499
|
+
}
|
|
16500
|
+
liquidMethodMissing(key) {
|
|
16501
|
+
switch (typeof key) {
|
|
16502
|
+
case "string":
|
|
16503
|
+
return this.#map.get(key);
|
|
16504
|
+
case "object": {
|
|
16505
|
+
if (key !== null && "handle" in key) {
|
|
16506
|
+
const { handle } = key;
|
|
16507
|
+
if (typeof handle === "string") {
|
|
16508
|
+
return this.#map.get(handle);
|
|
16509
|
+
}
|
|
16510
|
+
}
|
|
16511
|
+
break;
|
|
16512
|
+
}
|
|
16513
|
+
default:
|
|
16514
|
+
break;
|
|
16515
|
+
}
|
|
16516
|
+
}
|
|
16517
|
+
};
|
|
16518
|
+
|
|
16519
|
+
// src/compatibility/drops/pages.ts
|
|
16520
|
+
var import_liquidjs9 = require("liquidjs");
|
|
16521
|
+
var PagesDrop = class extends import_liquidjs9.Drop {
|
|
16522
|
+
#instance;
|
|
16523
|
+
#map;
|
|
16524
|
+
constructor(instance) {
|
|
16525
|
+
super();
|
|
16526
|
+
this.#instance = instance;
|
|
16527
|
+
this.#map = /* @__PURE__ */ new Map();
|
|
16528
|
+
}
|
|
16529
|
+
liquidMethodMissing(key) {
|
|
16530
|
+
switch (typeof key) {
|
|
16531
|
+
case "string": {
|
|
16532
|
+
return this.getPage(key);
|
|
16533
|
+
}
|
|
16534
|
+
case "object": {
|
|
16535
|
+
if (key !== null) {
|
|
16536
|
+
const obj = key;
|
|
16537
|
+
const id = obj.handle || obj.id || obj._id;
|
|
16538
|
+
if (isLikePromise(id)) {
|
|
16539
|
+
return id.then((id2) => this.getPage(id2));
|
|
16540
|
+
}
|
|
16541
|
+
return this.getPage(id);
|
|
16542
|
+
}
|
|
16543
|
+
break;
|
|
16544
|
+
}
|
|
16545
|
+
default:
|
|
16546
|
+
break;
|
|
16547
|
+
}
|
|
16548
|
+
}
|
|
16549
|
+
getPage(slug) {
|
|
16550
|
+
let resource = this.#map.get(slug);
|
|
16551
|
+
if (resource === void 0) {
|
|
16552
|
+
resource = ShopifyPage(
|
|
16553
|
+
this.#instance,
|
|
16554
|
+
new SwellStorefrontRecord(this.#instance.swell, "content/pages", slug)
|
|
16555
|
+
);
|
|
16556
|
+
this.#map.set(slug, resource);
|
|
16557
|
+
}
|
|
16558
|
+
return resource;
|
|
16559
|
+
}
|
|
16560
|
+
};
|
|
16561
|
+
var Pages = class extends SwellStorefrontCollection {
|
|
16562
|
+
#drop;
|
|
16563
|
+
constructor(instance) {
|
|
16564
|
+
super(instance.swell, "content/pages", {}, async () => {
|
|
16565
|
+
const response = await this._defaultGetter().call(this);
|
|
16566
|
+
if (!response) {
|
|
16567
|
+
return null;
|
|
16568
|
+
}
|
|
16569
|
+
return {
|
|
16570
|
+
...response,
|
|
16571
|
+
page_count: response.page_count || 0,
|
|
16572
|
+
results: response.results.map((page) => ShopifyPage(instance, page))
|
|
16573
|
+
};
|
|
16574
|
+
});
|
|
16575
|
+
this.#drop = new PagesDrop(instance);
|
|
16576
|
+
}
|
|
16577
|
+
toLiquid() {
|
|
16578
|
+
return this.#drop;
|
|
16579
|
+
}
|
|
16580
|
+
};
|
|
16581
|
+
|
|
16320
16582
|
// src/compatibility/shopify.ts
|
|
16321
|
-
var
|
|
16583
|
+
var ShopifyCompatibility2 = class {
|
|
16322
16584
|
theme;
|
|
16323
16585
|
swell;
|
|
16324
16586
|
pageId;
|
|
@@ -16339,9 +16601,25 @@ var ShopifyCompatibility3 = class {
|
|
|
16339
16601
|
}
|
|
16340
16602
|
initGlobals(globals) {
|
|
16341
16603
|
const { request, page } = globals;
|
|
16604
|
+
globals.additional_checkout_buttons = false;
|
|
16605
|
+
globals.all_products = new AllProductsDrop(this);
|
|
16606
|
+
globals.articles = new ArticlesDrop(this);
|
|
16607
|
+
globals.blogs = new BlogsDrop(this);
|
|
16608
|
+
globals.closest = {};
|
|
16609
|
+
globals.collections = new Collections(this);
|
|
16610
|
+
globals.content_for_additional_checkout_buttons = "";
|
|
16611
|
+
globals.content_for_header = "";
|
|
16612
|
+
globals.content_for_index = "";
|
|
16613
|
+
globals.content_for_layout = "";
|
|
16614
|
+
globals.current_page = this.swell.queryParams.page || 1;
|
|
16615
|
+
globals.images = new ImagesDrop(this);
|
|
16616
|
+
globals.linklists = null;
|
|
16617
|
+
globals.localization = null;
|
|
16618
|
+
globals.metaobjects = {};
|
|
16342
16619
|
globals.page = {
|
|
16343
16620
|
...page || void 0
|
|
16344
16621
|
};
|
|
16622
|
+
globals.pages = new Pages(this);
|
|
16345
16623
|
globals.request = {
|
|
16346
16624
|
...request || void 0,
|
|
16347
16625
|
design_mode: this.swell.isEditor,
|
|
@@ -16349,9 +16627,11 @@ var ShopifyCompatibility3 = class {
|
|
|
16349
16627
|
// TODO: Add support for visual section preview
|
|
16350
16628
|
page_type: page?.id
|
|
16351
16629
|
};
|
|
16352
|
-
globals.collections = new CollectionsDrop(this);
|
|
16353
|
-
globals.current_page = this.swell.queryParams.page || 1;
|
|
16354
16630
|
globals.routes = this.getPageRoutes();
|
|
16631
|
+
globals.scripts = {};
|
|
16632
|
+
globals.shop = null;
|
|
16633
|
+
globals.template = {};
|
|
16634
|
+
globals.theme = {};
|
|
16355
16635
|
}
|
|
16356
16636
|
adaptGlobals(globals, prevGlobals) {
|
|
16357
16637
|
if (globals.page) {
|
|
@@ -16372,11 +16652,6 @@ var ShopifyCompatibility3 = class {
|
|
|
16372
16652
|
if (globals.menus) {
|
|
16373
16653
|
globals.linklists = new ObjectHandlesDrop(globals.menus);
|
|
16374
16654
|
}
|
|
16375
|
-
if (globals.geo) {
|
|
16376
|
-
const countryOptions = this.getAllCountryOptionTags(globals.geo);
|
|
16377
|
-
globals.all_country_option_tags = countryOptions;
|
|
16378
|
-
globals.country_option_tags = countryOptions;
|
|
16379
|
-
}
|
|
16380
16655
|
if (globals.store) {
|
|
16381
16656
|
globals.shop = this.getShopData(globals.store);
|
|
16382
16657
|
const request = globals.request || prevGlobals.request;
|
|
@@ -16888,20 +17163,6 @@ ${injects.join("\n")}</script>`;
|
|
|
16888
17163
|
}
|
|
16889
17164
|
];
|
|
16890
17165
|
}
|
|
16891
|
-
getAllCountryOptionTags(geoSettings) {
|
|
16892
|
-
if (!geoSettings) {
|
|
16893
|
-
return "";
|
|
16894
|
-
}
|
|
16895
|
-
return geoSettings.countries?.map((country) => {
|
|
16896
|
-
if (!country) return "";
|
|
16897
|
-
const provinces = (geoSettings.states || []).filter((state) => state.country === country.id).map((state) => [state.id, state.name]);
|
|
16898
|
-
const provincesEncoded = JSON.stringify(provinces).replace(
|
|
16899
|
-
/"/g,
|
|
16900
|
-
"""
|
|
16901
|
-
);
|
|
16902
|
-
return `<option value="${country.id}" data-provinces="${provincesEncoded}">${country.name}</option>`;
|
|
16903
|
-
}).filter(Boolean).join("\n");
|
|
16904
|
-
}
|
|
16905
17166
|
// returns true if this URL is used for script actions
|
|
16906
17167
|
isScriptFormActionUrl(url) {
|
|
16907
17168
|
if (!url) {
|
|
@@ -16957,25 +17218,41 @@ function ShopifyTemplate(_instance, template) {
|
|
|
16957
17218
|
);
|
|
16958
17219
|
}
|
|
16959
17220
|
|
|
16960
|
-
// src/
|
|
16961
|
-
var
|
|
16962
|
-
var
|
|
17221
|
+
// src/liquid/drops/render.ts
|
|
17222
|
+
var import_liquidjs10 = require("liquidjs");
|
|
17223
|
+
var import_lodash_es8 = require("lodash-es");
|
|
17224
|
+
var RenderDrop = class extends import_liquidjs10.Drop {
|
|
17225
|
+
#result;
|
|
17226
|
+
#handler;
|
|
16963
17227
|
constructor(handler) {
|
|
16964
17228
|
super();
|
|
16965
|
-
this
|
|
17229
|
+
this.#result = void 0;
|
|
17230
|
+
this.#handler = handler;
|
|
16966
17231
|
}
|
|
16967
|
-
|
|
16968
|
-
|
|
17232
|
+
/**
|
|
17233
|
+
* For `Drop` we usually use `valueOf` to convert the `object` to a `string`.
|
|
17234
|
+
* Use `then` instead of `valueOf` since `valueOf` doesn't work for `Promise`.
|
|
17235
|
+
*/
|
|
17236
|
+
then(onfulfilled, onrejected) {
|
|
17237
|
+
if (this.#handler !== import_lodash_es8.noop) {
|
|
17238
|
+
this.#result = Promise.resolve().then(this.#handler).then((result) => {
|
|
17239
|
+
this.#result = result;
|
|
17240
|
+
return this.#result;
|
|
17241
|
+
}).then(onfulfilled, onrejected);
|
|
17242
|
+
this.#handler = import_lodash_es8.noop;
|
|
17243
|
+
return;
|
|
17244
|
+
}
|
|
17245
|
+
onfulfilled(this.#result);
|
|
16969
17246
|
}
|
|
16970
17247
|
};
|
|
16971
17248
|
|
|
16972
17249
|
// src/liquid/index.ts
|
|
16973
|
-
var
|
|
17250
|
+
var import_liquidjs30 = require("liquidjs");
|
|
16974
17251
|
|
|
16975
17252
|
// src/liquid/tags/assign.ts
|
|
16976
|
-
var
|
|
17253
|
+
var import_liquidjs11 = require("liquidjs");
|
|
16977
17254
|
function bind(_liquidSwell) {
|
|
16978
|
-
return class AssignTag extends
|
|
17255
|
+
return class AssignTag extends import_liquidjs11.Tag {
|
|
16979
17256
|
key;
|
|
16980
17257
|
value;
|
|
16981
17258
|
identifier;
|
|
@@ -16987,7 +17264,7 @@ function bind(_liquidSwell) {
|
|
|
16987
17264
|
this.tokenizer.skipBlank();
|
|
16988
17265
|
this.tokenizer.advance();
|
|
16989
17266
|
try {
|
|
16990
|
-
this.value = new
|
|
17267
|
+
this.value = new import_liquidjs11.Value(this.tokenizer.readFilteredValue(), this.liquid);
|
|
16991
17268
|
} catch (e) {
|
|
16992
17269
|
console.warn(
|
|
16993
17270
|
`Liquid "assign" tag: ${e instanceof Error ? e.stack : String(e)}`
|
|
@@ -17014,9 +17291,9 @@ function bind(_liquidSwell) {
|
|
|
17014
17291
|
}
|
|
17015
17292
|
|
|
17016
17293
|
// src/liquid/tags/case.ts
|
|
17017
|
-
var
|
|
17294
|
+
var import_liquidjs12 = require("liquidjs");
|
|
17018
17295
|
function bind2(liquidSwell) {
|
|
17019
|
-
return class CaseTag extends
|
|
17296
|
+
return class CaseTag extends import_liquidjs12.Tag {
|
|
17020
17297
|
value;
|
|
17021
17298
|
branches;
|
|
17022
17299
|
elseTemplates;
|
|
@@ -17027,7 +17304,7 @@ function bind2(liquidSwell) {
|
|
|
17027
17304
|
const caseVar = this.tokenizer.readValue()?.getText();
|
|
17028
17305
|
this.isBlock = Boolean(caseVar?.startsWith("block."));
|
|
17029
17306
|
this.tokenizer.p = begin;
|
|
17030
|
-
this.value = new
|
|
17307
|
+
this.value = new import_liquidjs12.Value(this.tokenizer.readFilteredValue(), this.liquid);
|
|
17031
17308
|
this.branches = [];
|
|
17032
17309
|
this.elseTemplates = [];
|
|
17033
17310
|
let p = [];
|
|
@@ -17065,12 +17342,12 @@ function bind2(liquidSwell) {
|
|
|
17065
17342
|
}
|
|
17066
17343
|
*render(ctx, emitter) {
|
|
17067
17344
|
const r = this.liquid.renderer;
|
|
17068
|
-
const target = (0,
|
|
17345
|
+
const target = (0, import_liquidjs12.toValue)(yield this.value.value(ctx, ctx.opts.lenientIf));
|
|
17069
17346
|
let branchHit = false;
|
|
17070
17347
|
let output = "";
|
|
17071
17348
|
for (const branch of this.branches) {
|
|
17072
17349
|
for (const valueToken of branch.values) {
|
|
17073
|
-
const value = yield (0,
|
|
17350
|
+
const value = yield (0, import_liquidjs12.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
|
|
17074
17351
|
if (target === value) {
|
|
17075
17352
|
const blockOutput = yield r.renderTemplates(branch.templates, ctx);
|
|
17076
17353
|
output += this.isBlock && liquidSwell.isEditor ? `<span class="swell-block">${blockOutput}</span>` : blockOutput;
|
|
@@ -17103,15 +17380,15 @@ function bind2(liquidSwell) {
|
|
|
17103
17380
|
}
|
|
17104
17381
|
|
|
17105
17382
|
// src/liquid/tags/comment.ts
|
|
17106
|
-
var
|
|
17383
|
+
var import_liquidjs13 = require("liquidjs");
|
|
17107
17384
|
function bind3(_liquidSwell) {
|
|
17108
|
-
return class CommentTag extends
|
|
17385
|
+
return class CommentTag extends import_liquidjs13.Tag {
|
|
17109
17386
|
constructor(tagToken, remainTokens, liquid) {
|
|
17110
17387
|
super(tagToken, remainTokens, liquid);
|
|
17111
17388
|
let nested = 1;
|
|
17112
17389
|
while (remainTokens.length > 0) {
|
|
17113
17390
|
const token = remainTokens.shift();
|
|
17114
|
-
if (
|
|
17391
|
+
if (import_liquidjs13.TypeGuards.isTagToken(token)) {
|
|
17115
17392
|
switch (token.name) {
|
|
17116
17393
|
case "comment":
|
|
17117
17394
|
nested += 1;
|
|
@@ -17136,20 +17413,22 @@ function bind3(_liquidSwell) {
|
|
|
17136
17413
|
}
|
|
17137
17414
|
|
|
17138
17415
|
// src/liquid/tags/for.ts
|
|
17139
|
-
var
|
|
17416
|
+
var import_liquidjs14 = require("liquidjs");
|
|
17140
17417
|
var MODIFIERS = Object.freeze(["offset", "limit", "reversed"]);
|
|
17141
17418
|
function bind4(_liquidSwell) {
|
|
17142
|
-
return class ForTag extends
|
|
17419
|
+
return class ForTag extends import_liquidjs14.ForTag {
|
|
17143
17420
|
*render(ctx, emitter) {
|
|
17144
17421
|
const r = this.liquid.renderer;
|
|
17145
|
-
let collection = yield (0,
|
|
17422
|
+
let collection = yield (0, import_liquidjs14.evalToken)(this.collection, ctx);
|
|
17146
17423
|
collection = yield resolveEnumerable(collection);
|
|
17147
17424
|
if (!collection.length) {
|
|
17148
17425
|
yield r.renderTemplates(this.elseTemplates, ctx, emitter);
|
|
17149
17426
|
return;
|
|
17150
17427
|
}
|
|
17151
17428
|
const continueKey = "continue-" + this.variable + "-" + this.collection.getText();
|
|
17152
|
-
ctx.push({
|
|
17429
|
+
ctx.push({
|
|
17430
|
+
continue: ctx.getRegister(continueKey)
|
|
17431
|
+
});
|
|
17153
17432
|
const hash = yield this.hash.render(ctx);
|
|
17154
17433
|
ctx.pop();
|
|
17155
17434
|
const modifiers = this.liquid.options.orderedFilterParameters ? Object.keys(hash).filter((x) => MODIFIERS.includes(x)) : MODIFIERS.filter((x) => hash[x] !== void 0);
|
|
@@ -17165,23 +17444,29 @@ function bind4(_liquidSwell) {
|
|
|
17165
17444
|
return collection2;
|
|
17166
17445
|
}
|
|
17167
17446
|
}, collection);
|
|
17168
|
-
|
|
17447
|
+
const length = Math.min(collection.length, 50);
|
|
17448
|
+
const parent = ctx.getRegister("parentloop");
|
|
17449
|
+
ctx.setRegister(continueKey, (hash["offset"] || 0) + length);
|
|
17450
|
+
const forloop = new ForloopDrop(
|
|
17451
|
+
length,
|
|
17452
|
+
this.collection.getText(),
|
|
17453
|
+
this.variable,
|
|
17454
|
+
parent
|
|
17455
|
+
);
|
|
17169
17456
|
const scope = {
|
|
17170
|
-
forloop
|
|
17171
|
-
collection.length,
|
|
17172
|
-
this.collection.getText(),
|
|
17173
|
-
this.variable
|
|
17174
|
-
)
|
|
17457
|
+
forloop
|
|
17175
17458
|
};
|
|
17176
17459
|
ctx.push(scope);
|
|
17177
|
-
|
|
17178
|
-
|
|
17460
|
+
ctx.setRegister("parentloop", forloop);
|
|
17461
|
+
for (let i = 0; i < length; ++i) {
|
|
17462
|
+
scope[this.variable] = collection[i];
|
|
17179
17463
|
ctx.continueCalled = ctx.breakCalled = false;
|
|
17180
17464
|
yield r.renderTemplates(this.templates, ctx, emitter);
|
|
17181
17465
|
if (ctx.breakCalled) break;
|
|
17182
17466
|
scope.forloop.next();
|
|
17183
17467
|
}
|
|
17184
17468
|
ctx.continueCalled = ctx.breakCalled = false;
|
|
17469
|
+
ctx.setRegister("parentloop", parent);
|
|
17185
17470
|
ctx.pop();
|
|
17186
17471
|
}
|
|
17187
17472
|
};
|
|
@@ -17197,10 +17482,10 @@ function limit(arr, count) {
|
|
|
17197
17482
|
}
|
|
17198
17483
|
|
|
17199
17484
|
// src/liquid/tags/form.ts
|
|
17200
|
-
var
|
|
17485
|
+
var import_liquidjs15 = require("liquidjs");
|
|
17201
17486
|
var IGNORED_SHOPIFY_FORMS = Object.freeze(["new_comment", "guest_login"]);
|
|
17202
17487
|
function bind5(liquidSwell) {
|
|
17203
|
-
return class FormTag extends
|
|
17488
|
+
return class FormTag extends import_liquidjs15.Tag {
|
|
17204
17489
|
formType;
|
|
17205
17490
|
formConfig;
|
|
17206
17491
|
templates;
|
|
@@ -17214,10 +17499,10 @@ function bind5(liquidSwell) {
|
|
|
17214
17499
|
tokenizer.advance();
|
|
17215
17500
|
this.arg = tokenizer.readValue();
|
|
17216
17501
|
this.templates = [];
|
|
17217
|
-
this.hash = new
|
|
17502
|
+
this.hash = new import_liquidjs15.Hash(this.tokenizer.remaining());
|
|
17218
17503
|
while (remainTokens.length > 0) {
|
|
17219
17504
|
const token2 = remainTokens.shift();
|
|
17220
|
-
if (
|
|
17505
|
+
if (import_liquidjs15.TypeGuards.isTagToken(token2) && token2.name === "endform") {
|
|
17221
17506
|
return;
|
|
17222
17507
|
}
|
|
17223
17508
|
this.templates.push(parser.parseToken(token2, remainTokens));
|
|
@@ -17235,7 +17520,7 @@ function bind5(liquidSwell) {
|
|
|
17235
17520
|
return;
|
|
17236
17521
|
}
|
|
17237
17522
|
const r = this.liquid.renderer;
|
|
17238
|
-
const arg = yield (0,
|
|
17523
|
+
const arg = yield (0, import_liquidjs15.evalToken)(this.arg, ctx);
|
|
17239
17524
|
const hash = yield this.hash.render(ctx);
|
|
17240
17525
|
const scope = ctx.getAll();
|
|
17241
17526
|
const attrs = " " + Object.entries(hash).reduce((acc, [key, value]) => {
|
|
@@ -17290,14 +17575,15 @@ function bind5(liquidSwell) {
|
|
|
17290
17575
|
${html}
|
|
17291
17576
|
</form>
|
|
17292
17577
|
`);
|
|
17578
|
+
ctx.pop();
|
|
17293
17579
|
}
|
|
17294
17580
|
};
|
|
17295
17581
|
}
|
|
17296
17582
|
|
|
17297
17583
|
// src/liquid/tags/if.ts
|
|
17298
|
-
var
|
|
17584
|
+
var import_liquidjs16 = require("liquidjs");
|
|
17299
17585
|
function bind6(_liquidSwell) {
|
|
17300
|
-
return class IfTag extends
|
|
17586
|
+
return class IfTag extends import_liquidjs16.Tag {
|
|
17301
17587
|
branches = [];
|
|
17302
17588
|
elseTemplates;
|
|
17303
17589
|
constructor(tagToken, remainTokens, liquid, parser) {
|
|
@@ -17306,22 +17592,22 @@ function bind6(_liquidSwell) {
|
|
|
17306
17592
|
parser.parseStream(remainTokens).on(
|
|
17307
17593
|
"start",
|
|
17308
17594
|
() => this.branches.push({
|
|
17309
|
-
value: new
|
|
17595
|
+
value: new import_liquidjs16.Value(
|
|
17310
17596
|
tagToken.tokenizer.readFilteredValue(),
|
|
17311
17597
|
this.liquid
|
|
17312
17598
|
),
|
|
17313
17599
|
templates: p = []
|
|
17314
17600
|
})
|
|
17315
17601
|
).on("tag:elsif", (token) => {
|
|
17316
|
-
(0,
|
|
17602
|
+
(0, import_liquidjs16.assert)(!this.elseTemplates, "unexpected elsif after else");
|
|
17317
17603
|
this.branches.push({
|
|
17318
|
-
value: new
|
|
17604
|
+
value: new import_liquidjs16.Value(token.tokenizer.readFilteredValue(), this.liquid),
|
|
17319
17605
|
templates: p = []
|
|
17320
17606
|
});
|
|
17321
17607
|
}).on("tag:else", (tag) => {
|
|
17322
17608
|
if (tag.args.length > 0) {
|
|
17323
17609
|
this.branches.push({
|
|
17324
|
-
value: new
|
|
17610
|
+
value: new import_liquidjs16.Value(tag.tokenizer.readFilteredValue(), this.liquid),
|
|
17325
17611
|
templates: p = []
|
|
17326
17612
|
});
|
|
17327
17613
|
} else {
|
|
@@ -17339,7 +17625,7 @@ function bind6(_liquidSwell) {
|
|
|
17339
17625
|
const r = this.liquid.renderer;
|
|
17340
17626
|
for (const { value, templates } of this.branches) {
|
|
17341
17627
|
const v = yield value.value(ctx, ctx.opts.lenientIf);
|
|
17342
|
-
if ((0,
|
|
17628
|
+
if ((0, import_liquidjs16.isTruthy)(v, ctx)) {
|
|
17343
17629
|
yield r.renderTemplates(templates, ctx, emitter);
|
|
17344
17630
|
return;
|
|
17345
17631
|
}
|
|
@@ -17360,20 +17646,20 @@ function bind6(_liquidSwell) {
|
|
|
17360
17646
|
};
|
|
17361
17647
|
}
|
|
17362
17648
|
function assertEmpty(predicate, message = `unexpected ${JSON.stringify(predicate)}`) {
|
|
17363
|
-
(0,
|
|
17649
|
+
(0, import_liquidjs16.assert)(!predicate, message);
|
|
17364
17650
|
}
|
|
17365
17651
|
|
|
17366
17652
|
// src/liquid/tags/javascript.ts
|
|
17367
|
-
var
|
|
17653
|
+
var import_liquidjs17 = require("liquidjs");
|
|
17368
17654
|
function bind7(_liquidSwell) {
|
|
17369
|
-
return class JavascriptTag extends
|
|
17655
|
+
return class JavascriptTag extends import_liquidjs17.Tag {
|
|
17370
17656
|
templates;
|
|
17371
17657
|
constructor(token, remainTokens, liquid, parser) {
|
|
17372
17658
|
super(token, remainTokens, liquid);
|
|
17373
17659
|
this.templates = [];
|
|
17374
17660
|
while (remainTokens.length > 0) {
|
|
17375
17661
|
const token2 = remainTokens.shift();
|
|
17376
|
-
if (
|
|
17662
|
+
if (import_liquidjs17.TypeGuards.isTagToken(token2) && token2.name === "endjavascript") {
|
|
17377
17663
|
return;
|
|
17378
17664
|
}
|
|
17379
17665
|
this.templates.push(parser.parseToken(token2, remainTokens));
|
|
@@ -17391,9 +17677,9 @@ function bind7(_liquidSwell) {
|
|
|
17391
17677
|
}
|
|
17392
17678
|
|
|
17393
17679
|
// src/liquid/tags/layout.ts
|
|
17394
|
-
var
|
|
17680
|
+
var import_liquidjs18 = require("liquidjs");
|
|
17395
17681
|
function bind8(liquidSwell) {
|
|
17396
|
-
return class LayoutTag extends
|
|
17682
|
+
return class LayoutTag extends import_liquidjs18.Tag {
|
|
17397
17683
|
fileName;
|
|
17398
17684
|
constructor(token, remainTokens, liquid, _parser) {
|
|
17399
17685
|
super(token, remainTokens, liquid);
|
|
@@ -17409,9 +17695,9 @@ function bind8(liquidSwell) {
|
|
|
17409
17695
|
}
|
|
17410
17696
|
|
|
17411
17697
|
// src/liquid/tags/paginate.ts
|
|
17412
|
-
var
|
|
17698
|
+
var import_liquidjs19 = require("liquidjs");
|
|
17413
17699
|
function bind9(liquidSwell) {
|
|
17414
|
-
return class PaginateTag extends
|
|
17700
|
+
return class PaginateTag extends import_liquidjs19.Tag {
|
|
17415
17701
|
collection;
|
|
17416
17702
|
pageSize;
|
|
17417
17703
|
templates;
|
|
@@ -17426,7 +17712,7 @@ function bind9(liquidSwell) {
|
|
|
17426
17712
|
}
|
|
17427
17713
|
this.templates = [];
|
|
17428
17714
|
this.collection = collection;
|
|
17429
|
-
this.hash = new
|
|
17715
|
+
this.hash = new import_liquidjs19.Hash(this.tokenizer.remaining());
|
|
17430
17716
|
const stream = parser.parseStream(remainTokens).on("tag:endpaginate", () => stream.stop()).on("template", (tpl) => {
|
|
17431
17717
|
this.templates.push(tpl);
|
|
17432
17718
|
}).on("end", () => {
|
|
@@ -17436,10 +17722,10 @@ function bind9(liquidSwell) {
|
|
|
17436
17722
|
}
|
|
17437
17723
|
*render(ctx, emitter) {
|
|
17438
17724
|
const r = this.liquid.renderer;
|
|
17439
|
-
const collection = yield (0,
|
|
17440
|
-
const pageSize = Number(yield (0,
|
|
17725
|
+
const collection = yield (0, import_liquidjs19.evalToken)(this.collection, ctx);
|
|
17726
|
+
const pageSize = Number(yield (0, import_liquidjs19.evalToken)(this.pageSize, ctx));
|
|
17441
17727
|
const hash = yield this.hash.render(ctx);
|
|
17442
|
-
if (!Number.isNaN(pageSize) && collection instanceof SwellStorefrontCollection && collection.limit
|
|
17728
|
+
if (!Number.isNaN(pageSize) && collection instanceof SwellStorefrontCollection && collection.limit !== pageSize) {
|
|
17443
17729
|
yield collection._get({
|
|
17444
17730
|
limit: pageSize,
|
|
17445
17731
|
window: hash.window_size || void 0
|
|
@@ -17455,15 +17741,18 @@ function bind9(liquidSwell) {
|
|
|
17455
17741
|
ctx.push({ paginate });
|
|
17456
17742
|
}
|
|
17457
17743
|
yield r.renderTemplates(this.templates, ctx, emitter);
|
|
17744
|
+
if (collection) {
|
|
17745
|
+
ctx.pop();
|
|
17746
|
+
}
|
|
17458
17747
|
}
|
|
17459
17748
|
};
|
|
17460
17749
|
}
|
|
17461
17750
|
|
|
17462
17751
|
// src/liquid/tags/render.ts
|
|
17463
|
-
var
|
|
17464
|
-
var
|
|
17752
|
+
var import_lodash_es9 = require("lodash-es");
|
|
17753
|
+
var import_liquidjs20 = require("liquidjs");
|
|
17465
17754
|
function bind10(liquidSwell) {
|
|
17466
|
-
return class RenderTag extends
|
|
17755
|
+
return class RenderTag extends import_liquidjs20.RenderTag {
|
|
17467
17756
|
*render(ctx, emitter) {
|
|
17468
17757
|
const { liquid, hash } = this;
|
|
17469
17758
|
const filepath = yield renderFilePath(
|
|
@@ -17471,23 +17760,23 @@ function bind10(liquidSwell) {
|
|
|
17471
17760
|
ctx,
|
|
17472
17761
|
liquid
|
|
17473
17762
|
);
|
|
17474
|
-
(0,
|
|
17763
|
+
(0, import_liquidjs20.assert)(filepath, () => `illegal file path "${filepath}"`);
|
|
17475
17764
|
const themeConfig = yield liquidSwell.getComponentPath(filepath).then(
|
|
17476
17765
|
(fileName) => liquidSwell.getThemeConfig(fileName)
|
|
17477
17766
|
);
|
|
17478
17767
|
const childCtx = ctx.spawn();
|
|
17479
17768
|
const scope = childCtx.bottom();
|
|
17480
|
-
(0,
|
|
17769
|
+
(0, import_lodash_es9.assign)(scope, yield hash.render(ctx));
|
|
17481
17770
|
const parentSection = yield ctx._get(["section"]);
|
|
17482
|
-
if (parentSection) (0,
|
|
17771
|
+
if (parentSection) (0, import_lodash_es9.assign)(scope, { section: parentSection });
|
|
17483
17772
|
if (this["with"]) {
|
|
17484
17773
|
const { value, alias } = this["with"];
|
|
17485
17774
|
const aliasName = alias || filepath;
|
|
17486
|
-
scope[aliasName] = yield (0,
|
|
17775
|
+
scope[aliasName] = yield (0, import_liquidjs20.evalToken)(value, ctx);
|
|
17487
17776
|
}
|
|
17488
17777
|
if (this["for"]) {
|
|
17489
17778
|
const { value, alias } = this["for"];
|
|
17490
|
-
let collection = yield (0,
|
|
17779
|
+
let collection = yield (0, import_liquidjs20.evalToken)(value, ctx);
|
|
17491
17780
|
collection = yield resolveEnumerable(collection);
|
|
17492
17781
|
scope["forloop"] = new ForloopDrop(
|
|
17493
17782
|
collection.length,
|
|
@@ -17520,13 +17809,13 @@ function* renderFilePath(file, ctx, liquid) {
|
|
|
17520
17809
|
default:
|
|
17521
17810
|
break;
|
|
17522
17811
|
}
|
|
17523
|
-
return yield (0,
|
|
17812
|
+
return yield (0, import_liquidjs20.evalToken)(file, ctx);
|
|
17524
17813
|
}
|
|
17525
17814
|
|
|
17526
17815
|
// src/liquid/tags/section.ts
|
|
17527
|
-
var
|
|
17816
|
+
var import_liquidjs21 = require("liquidjs");
|
|
17528
17817
|
function bind11(liquidSwell) {
|
|
17529
|
-
return class SectionTag extends
|
|
17818
|
+
return class SectionTag extends import_liquidjs21.Tag {
|
|
17530
17819
|
fileName;
|
|
17531
17820
|
constructor(token, remainTokens, liquid, _parser) {
|
|
17532
17821
|
super(token, remainTokens, liquid);
|
|
@@ -17558,7 +17847,8 @@ function bind11(liquidSwell) {
|
|
|
17558
17847
|
section: {
|
|
17559
17848
|
id: this.fileName,
|
|
17560
17849
|
settings: { ...defaultSettings, blocks: void 0 },
|
|
17561
|
-
blocks: defaultSettings.blocks
|
|
17850
|
+
blocks: defaultSettings.blocks,
|
|
17851
|
+
location: "static"
|
|
17562
17852
|
}
|
|
17563
17853
|
});
|
|
17564
17854
|
});
|
|
@@ -17576,10 +17866,10 @@ function bind11(liquidSwell) {
|
|
|
17576
17866
|
}
|
|
17577
17867
|
|
|
17578
17868
|
// src/liquid/tags/sections.ts
|
|
17579
|
-
var
|
|
17869
|
+
var import_liquidjs22 = require("liquidjs");
|
|
17580
17870
|
var import_json54 = __toESM(require("json5"), 1);
|
|
17581
17871
|
function bind12(liquidSwell) {
|
|
17582
|
-
return class SectionsTag extends
|
|
17872
|
+
return class SectionsTag extends import_liquidjs22.Tag {
|
|
17583
17873
|
fileName;
|
|
17584
17874
|
constructor(token, remainTokens, liquid, _parser) {
|
|
17585
17875
|
super(token, remainTokens, liquid);
|
|
@@ -17618,9 +17908,9 @@ function bind12(liquidSwell) {
|
|
|
17618
17908
|
}
|
|
17619
17909
|
|
|
17620
17910
|
// src/liquid/tags/style.ts
|
|
17621
|
-
var
|
|
17911
|
+
var import_liquidjs23 = require("liquidjs");
|
|
17622
17912
|
function bind13(_liquidSwell) {
|
|
17623
|
-
return class StyleTag extends
|
|
17913
|
+
return class StyleTag extends import_liquidjs23.Tag {
|
|
17624
17914
|
templates;
|
|
17625
17915
|
hash;
|
|
17626
17916
|
constructor(token, remainTokens, liquid, parser) {
|
|
@@ -17629,7 +17919,7 @@ function bind13(_liquidSwell) {
|
|
|
17629
17919
|
const tagBegin = token.begin;
|
|
17630
17920
|
while (remainTokens.length > 0) {
|
|
17631
17921
|
const token2 = remainTokens.shift();
|
|
17632
|
-
if (
|
|
17922
|
+
if (import_liquidjs23.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
|
|
17633
17923
|
this.hash = md5(token2.input.slice(tagBegin, token2.end));
|
|
17634
17924
|
return;
|
|
17635
17925
|
}
|
|
@@ -17652,16 +17942,16 @@ function bind13(_liquidSwell) {
|
|
|
17652
17942
|
}
|
|
17653
17943
|
|
|
17654
17944
|
// src/liquid/tags/stylesheet.ts
|
|
17655
|
-
var
|
|
17945
|
+
var import_liquidjs24 = require("liquidjs");
|
|
17656
17946
|
function bind14(_liquidSwell) {
|
|
17657
|
-
return class StyleSheetTag extends
|
|
17947
|
+
return class StyleSheetTag extends import_liquidjs24.Tag {
|
|
17658
17948
|
templates;
|
|
17659
17949
|
constructor(token, remainTokens, liquid, parser) {
|
|
17660
17950
|
super(token, remainTokens, liquid);
|
|
17661
17951
|
this.templates = [];
|
|
17662
17952
|
while (remainTokens.length > 0) {
|
|
17663
17953
|
const token2 = remainTokens.shift();
|
|
17664
|
-
if (
|
|
17954
|
+
if (import_liquidjs24.TypeGuards.isTagToken(token2) && token2.name === "endstylesheet") {
|
|
17665
17955
|
return;
|
|
17666
17956
|
}
|
|
17667
17957
|
this.templates.push(parser.parseToken(token2, remainTokens));
|
|
@@ -17677,9 +17967,9 @@ function bind14(_liquidSwell) {
|
|
|
17677
17967
|
}
|
|
17678
17968
|
|
|
17679
17969
|
// src/liquid/tags/shopify/include.ts
|
|
17680
|
-
var
|
|
17970
|
+
var import_liquidjs25 = require("liquidjs");
|
|
17681
17971
|
function bind15(liquidSwell) {
|
|
17682
|
-
return class IncludeTag extends
|
|
17972
|
+
return class IncludeTag extends import_liquidjs25.IncludeTag {
|
|
17683
17973
|
*render(ctx, emitter) {
|
|
17684
17974
|
const { hash } = this;
|
|
17685
17975
|
const filepath = yield renderFilePath(
|
|
@@ -17687,13 +17977,13 @@ function bind15(liquidSwell) {
|
|
|
17687
17977
|
ctx,
|
|
17688
17978
|
this.liquid
|
|
17689
17979
|
);
|
|
17690
|
-
(0,
|
|
17980
|
+
(0, import_liquidjs25.assert)(filepath, () => `illegal file path "${filepath}"`);
|
|
17691
17981
|
const saved = ctx.saveRegister("blocks", "blockMode");
|
|
17692
17982
|
ctx.setRegister("blocks", {});
|
|
17693
17983
|
ctx.setRegister("blockMode", 0);
|
|
17694
17984
|
const scope = yield hash.render(ctx);
|
|
17695
17985
|
if (this.withVar) {
|
|
17696
|
-
scope[filepath] = yield (0,
|
|
17986
|
+
scope[filepath] = yield (0, import_liquidjs25.evalToken)(this.withVar, ctx);
|
|
17697
17987
|
}
|
|
17698
17988
|
ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
|
|
17699
17989
|
const output = yield liquidSwell.getComponentPath(filepath).then((path) => liquidSwell.getThemeConfig(path)).then((themeConfig) => liquidSwell.renderTemplate(themeConfig, scope));
|
|
@@ -17705,10 +17995,10 @@ function bind15(liquidSwell) {
|
|
|
17705
17995
|
}
|
|
17706
17996
|
|
|
17707
17997
|
// src/liquid/tags/shopify/schema.ts
|
|
17708
|
-
var
|
|
17998
|
+
var import_liquidjs26 = require("liquidjs");
|
|
17709
17999
|
var import_json55 = __toESM(require("json5"), 1);
|
|
17710
18000
|
function bind16(liquidSwell) {
|
|
17711
|
-
return class SchemaTag extends
|
|
18001
|
+
return class SchemaTag extends import_liquidjs26.Tag {
|
|
17712
18002
|
templates;
|
|
17713
18003
|
constructor(token, remainTokens, liquid, parser) {
|
|
17714
18004
|
super(token, remainTokens, liquid);
|
|
@@ -17741,9 +18031,9 @@ function bind16(liquidSwell) {
|
|
|
17741
18031
|
}
|
|
17742
18032
|
|
|
17743
18033
|
// src/liquid/tags/inline_editable.ts
|
|
17744
|
-
var
|
|
18034
|
+
var import_liquidjs27 = require("liquidjs");
|
|
17745
18035
|
function bind17(_liquidSwell) {
|
|
17746
|
-
return class InlineEditableTag extends
|
|
18036
|
+
return class InlineEditableTag extends import_liquidjs27.Tag {
|
|
17747
18037
|
key;
|
|
17748
18038
|
value;
|
|
17749
18039
|
constructor(token, remainTokens, liquid, _parser) {
|
|
@@ -17995,12 +18285,12 @@ function bind35(_liquidSwell) {
|
|
|
17995
18285
|
}
|
|
17996
18286
|
|
|
17997
18287
|
// src/liquid/filters/embedded_content.ts
|
|
17998
|
-
var
|
|
18288
|
+
var import_lodash_es10 = require("lodash-es");
|
|
17999
18289
|
function bind36(_liquidSwell) {
|
|
18000
18290
|
return (value, tag = "iframe") => {
|
|
18001
18291
|
const escapeIframes = value.replaceAll(`<${tag}`, `<${tag}`).replaceAll(`</${tag}`, `</${tag}`);
|
|
18002
18292
|
const removeTags = escapeIframes.replaceAll(/<(.*?)>/gi, "");
|
|
18003
|
-
const unescaped = (0,
|
|
18293
|
+
const unescaped = (0, import_lodash_es10.unescape)(removeTags);
|
|
18004
18294
|
const replaceSpaces = unescaped.replaceAll(" ", " ");
|
|
18005
18295
|
return replaceSpaces;
|
|
18006
18296
|
};
|
|
@@ -18075,10 +18365,10 @@ var format_address_default = {
|
|
|
18075
18365
|
};
|
|
18076
18366
|
|
|
18077
18367
|
// src/liquid/filters/handleize.ts
|
|
18078
|
-
var
|
|
18368
|
+
var import_lodash_es11 = require("lodash-es");
|
|
18079
18369
|
function bind40(_liquidSwell) {
|
|
18080
18370
|
return function filterHandleize(handle) {
|
|
18081
|
-
return (0,
|
|
18371
|
+
return (0, import_lodash_es11.kebabCase)(handle);
|
|
18082
18372
|
};
|
|
18083
18373
|
}
|
|
18084
18374
|
|
|
@@ -18803,9 +19093,9 @@ async function resolveAsyncProps(propArg, resolveProps) {
|
|
|
18803
19093
|
}
|
|
18804
19094
|
|
|
18805
19095
|
// src/liquid/operators.ts
|
|
18806
|
-
var
|
|
19096
|
+
var import_liquidjs28 = require("liquidjs");
|
|
18807
19097
|
var swellOperators = {
|
|
18808
|
-
...
|
|
19098
|
+
...import_liquidjs28.defaultOperators,
|
|
18809
19099
|
"==": equal,
|
|
18810
19100
|
"!=": (l, r) => !equal(l, r),
|
|
18811
19101
|
contains: (l, r) => {
|
|
@@ -18832,8 +19122,8 @@ function arrayEqual(lhs, rhs) {
|
|
|
18832
19122
|
|
|
18833
19123
|
// src/liquid/color.ts
|
|
18834
19124
|
var import_color = __toESM(require("color"), 1);
|
|
18835
|
-
var
|
|
18836
|
-
var ThemeColor = class _ThemeColor extends
|
|
19125
|
+
var import_liquidjs29 = require("liquidjs");
|
|
19126
|
+
var ThemeColor = class _ThemeColor extends import_liquidjs29.Drop {
|
|
18837
19127
|
color;
|
|
18838
19128
|
colorValues;
|
|
18839
19129
|
red;
|
|
@@ -18968,7 +19258,7 @@ function isThemeColorLike(value) {
|
|
|
18968
19258
|
}
|
|
18969
19259
|
|
|
18970
19260
|
// src/liquid/index.ts
|
|
18971
|
-
var LiquidSwell29 = class extends
|
|
19261
|
+
var LiquidSwell29 = class extends import_liquidjs30.Liquid {
|
|
18972
19262
|
theme;
|
|
18973
19263
|
getThemeConfig;
|
|
18974
19264
|
getThemeTemplateConfigByType;
|
|
@@ -19447,6 +19737,161 @@ var ThemeLoader = class _ThemeLoader {
|
|
|
19447
19737
|
}
|
|
19448
19738
|
};
|
|
19449
19739
|
|
|
19740
|
+
// src/globals.ts
|
|
19741
|
+
var import_lodash_es12 = require("lodash-es");
|
|
19742
|
+
|
|
19743
|
+
// src/compatibility/drops/robots-rule.ts
|
|
19744
|
+
var import_liquidjs31 = require("liquidjs");
|
|
19745
|
+
var RobotsRule = class _RobotsRule extends import_liquidjs31.Drop {
|
|
19746
|
+
constructor(directive, value) {
|
|
19747
|
+
super();
|
|
19748
|
+
this.directive = directive;
|
|
19749
|
+
this.value = value;
|
|
19750
|
+
}
|
|
19751
|
+
static from(directive, value) {
|
|
19752
|
+
return new _RobotsRule(directive, value);
|
|
19753
|
+
}
|
|
19754
|
+
valueOf() {
|
|
19755
|
+
return `${this.directive}: ${this.value}
|
|
19756
|
+
`;
|
|
19757
|
+
}
|
|
19758
|
+
};
|
|
19759
|
+
|
|
19760
|
+
// src/globals.ts
|
|
19761
|
+
async function getFirstFilledValue(values) {
|
|
19762
|
+
for (const promise of values) {
|
|
19763
|
+
const value = await promise;
|
|
19764
|
+
if (value) {
|
|
19765
|
+
return value;
|
|
19766
|
+
}
|
|
19767
|
+
}
|
|
19768
|
+
}
|
|
19769
|
+
function getRecordGlobals(theme, record) {
|
|
19770
|
+
const globals = {};
|
|
19771
|
+
globals.handle = new RenderDrop(() => record.slug);
|
|
19772
|
+
globals.page_title = new RenderDrop(
|
|
19773
|
+
() => getFirstFilledValue([
|
|
19774
|
+
record.meta_title,
|
|
19775
|
+
// filled SEO
|
|
19776
|
+
record.name,
|
|
19777
|
+
// all records
|
|
19778
|
+
record.title,
|
|
19779
|
+
// content/pages, content/blogs, content/blog-categories
|
|
19780
|
+
theme.page?.title,
|
|
19781
|
+
// default page title
|
|
19782
|
+
theme.globals.store?.name
|
|
19783
|
+
// fallback to store name
|
|
19784
|
+
])
|
|
19785
|
+
);
|
|
19786
|
+
globals.page_description = new RenderDrop(
|
|
19787
|
+
() => getFirstFilledValue([
|
|
19788
|
+
record.meta_description,
|
|
19789
|
+
// filled SEO
|
|
19790
|
+
record.description,
|
|
19791
|
+
// product and category
|
|
19792
|
+
record.summary,
|
|
19793
|
+
// content/blogs
|
|
19794
|
+
theme.page?.description
|
|
19795
|
+
])
|
|
19796
|
+
);
|
|
19797
|
+
globals.page_image = new RenderDrop(
|
|
19798
|
+
() => getFirstFilledValue([
|
|
19799
|
+
record.images,
|
|
19800
|
+
// product and category
|
|
19801
|
+
record.image
|
|
19802
|
+
// article
|
|
19803
|
+
]).then((images) => {
|
|
19804
|
+
if (typeof images !== "object" || images === null) {
|
|
19805
|
+
return;
|
|
19806
|
+
}
|
|
19807
|
+
const image = Array.isArray(images) ? images[0] : images;
|
|
19808
|
+
return image ? ShopifyImage(image) : void 0;
|
|
19809
|
+
})
|
|
19810
|
+
);
|
|
19811
|
+
return globals;
|
|
19812
|
+
}
|
|
19813
|
+
var POWERED_BY_LINK = '<a target="_blank" rel="nofollow" href="https://www.swell.is/?utm_campaign=poweredby&utm_medium=swell&utm_source=onlinestore">Powered by Swell</a>';
|
|
19814
|
+
function getAllCountryOptionTags(geoSettings) {
|
|
19815
|
+
if (!geoSettings) {
|
|
19816
|
+
return "";
|
|
19817
|
+
}
|
|
19818
|
+
const stateMap = (geoSettings.states || []).reduce((map, state) => {
|
|
19819
|
+
let list = map.get(state.country);
|
|
19820
|
+
if (list === void 0) {
|
|
19821
|
+
list = [];
|
|
19822
|
+
map.set(state.country, list);
|
|
19823
|
+
}
|
|
19824
|
+
list.push(state);
|
|
19825
|
+
return map;
|
|
19826
|
+
}, /* @__PURE__ */ new Map());
|
|
19827
|
+
return (geoSettings.countries || []).map((country) => {
|
|
19828
|
+
if (!country) return "";
|
|
19829
|
+
const provinces = (stateMap.get(country.id) || []).map((state) => [
|
|
19830
|
+
state.id,
|
|
19831
|
+
state.name
|
|
19832
|
+
]);
|
|
19833
|
+
const provincesEncoded = JSON.stringify(provinces).replace(
|
|
19834
|
+
/"/g,
|
|
19835
|
+
"""
|
|
19836
|
+
);
|
|
19837
|
+
return `<option value="${country.id}" data-provinces="${provincesEncoded}">${country.name}</option>`;
|
|
19838
|
+
}).filter(Boolean).join("\n");
|
|
19839
|
+
}
|
|
19840
|
+
function getRobotsGlobals(canonicalUrl) {
|
|
19841
|
+
const sitemapUrl = `${(0, import_lodash_es12.trimEnd)(canonicalUrl, "/")}/sitemap.xml`;
|
|
19842
|
+
const defaultRules = [
|
|
19843
|
+
{ directive: "Disallow", value: "/admin" },
|
|
19844
|
+
{ directive: "Disallow", value: "/cart" },
|
|
19845
|
+
{ directive: "Disallow", value: "/account" },
|
|
19846
|
+
{ directive: "Disallow", value: "/search" },
|
|
19847
|
+
{ directive: "Disallow", value: "/categories/*sort_by*" },
|
|
19848
|
+
{ directive: "Disallow", value: "/*/categories/*sort_by*" }
|
|
19849
|
+
];
|
|
19850
|
+
return {
|
|
19851
|
+
default_groups: [
|
|
19852
|
+
{
|
|
19853
|
+
user_agent: RobotsRule.from("User-agent", "*"),
|
|
19854
|
+
// sitemap: RobotsRule.from('Sitemap', sitemapUrl),
|
|
19855
|
+
rules: defaultRules.map(
|
|
19856
|
+
(rule) => RobotsRule.from(rule.directive, rule.value)
|
|
19857
|
+
)
|
|
19858
|
+
},
|
|
19859
|
+
{
|
|
19860
|
+
user_agent: RobotsRule.from("User-agent", "AhrefsBot"),
|
|
19861
|
+
// sitemap: RobotsRule.from('Sitemap', sitemapUrl),
|
|
19862
|
+
rules: [
|
|
19863
|
+
RobotsRule.from("Crawl-delay", "10"),
|
|
19864
|
+
...defaultRules.map(
|
|
19865
|
+
(rule) => RobotsRule.from(rule.directive, rule.value)
|
|
19866
|
+
)
|
|
19867
|
+
]
|
|
19868
|
+
},
|
|
19869
|
+
{
|
|
19870
|
+
user_agent: RobotsRule.from("User-agent", "AhrefsSiteAudit"),
|
|
19871
|
+
// sitemap: RobotsRule.from('Sitemap', sitemapUrl),
|
|
19872
|
+
rules: [
|
|
19873
|
+
RobotsRule.from("Crawl-delay", "10"),
|
|
19874
|
+
...defaultRules.map(
|
|
19875
|
+
(rule) => RobotsRule.from(rule.directive, rule.value)
|
|
19876
|
+
)
|
|
19877
|
+
]
|
|
19878
|
+
},
|
|
19879
|
+
{
|
|
19880
|
+
user_agent: RobotsRule.from("User-agent", "Nutch"),
|
|
19881
|
+
rules: [RobotsRule.from("Crawl-delay", "10")]
|
|
19882
|
+
},
|
|
19883
|
+
{
|
|
19884
|
+
user_agent: RobotsRule.from("User-agent", "MJ12bot"),
|
|
19885
|
+
rules: [RobotsRule.from("Crawl-delay", "10")]
|
|
19886
|
+
},
|
|
19887
|
+
{
|
|
19888
|
+
user_agent: RobotsRule.from("User-agent", "Pinterest"),
|
|
19889
|
+
rules: [RobotsRule.from("Crawl-delay", "1")]
|
|
19890
|
+
}
|
|
19891
|
+
]
|
|
19892
|
+
};
|
|
19893
|
+
}
|
|
19894
|
+
|
|
19450
19895
|
// src/theme.ts
|
|
19451
19896
|
var SwellTheme3 = class {
|
|
19452
19897
|
swell;
|
|
@@ -19460,7 +19905,7 @@ var SwellTheme3 = class {
|
|
|
19460
19905
|
page;
|
|
19461
19906
|
pageId;
|
|
19462
19907
|
shopifyCompatibility = null;
|
|
19463
|
-
shopifyCompatibilityClass =
|
|
19908
|
+
shopifyCompatibilityClass = ShopifyCompatibility2;
|
|
19464
19909
|
shopifyCompatibilityConfig = null;
|
|
19465
19910
|
formData = {};
|
|
19466
19911
|
globalData = {};
|
|
@@ -19475,7 +19920,7 @@ var SwellTheme3 = class {
|
|
|
19475
19920
|
this.globals = globals || {};
|
|
19476
19921
|
this.forms = forms;
|
|
19477
19922
|
this.resources = resources;
|
|
19478
|
-
this.shopifyCompatibilityClass = shopifyCompatibilityClass ||
|
|
19923
|
+
this.shopifyCompatibilityClass = shopifyCompatibilityClass || ShopifyCompatibility2;
|
|
19479
19924
|
this.liquidSwell = new LiquidSwell29({
|
|
19480
19925
|
theme: this,
|
|
19481
19926
|
getThemeConfig: this.getThemeConfig.bind(this),
|
|
@@ -19493,8 +19938,10 @@ var SwellTheme3 = class {
|
|
|
19493
19938
|
getSwellAppThemeProps(swellConfig) {
|
|
19494
19939
|
return swellConfig?.storefront?.theme || {};
|
|
19495
19940
|
}
|
|
19496
|
-
async initGlobals(pageId,
|
|
19941
|
+
async initGlobals(pageId, options) {
|
|
19497
19942
|
this.pageId = pageId;
|
|
19943
|
+
const pageRecord = options?.pageRecord;
|
|
19944
|
+
const altTemplate = options?.altTemplate;
|
|
19498
19945
|
const trace = createTraceId();
|
|
19499
19946
|
logger.debug("[SDK] Theme init start", { page: pageId, trace });
|
|
19500
19947
|
await this.themeLoader.init(this.themeConfigs || void 0);
|
|
@@ -19504,6 +19951,7 @@ var SwellTheme3 = class {
|
|
|
19504
19951
|
const { settings, request, page, cart, account, customer } = await this.resolvePageData(store, configs, pageId, altTemplate);
|
|
19505
19952
|
logger.debug("[SDK] Theme page data load done", { page: pageId, trace });
|
|
19506
19953
|
this.page = page;
|
|
19954
|
+
const countryOptions = getAllCountryOptionTags(geo);
|
|
19507
19955
|
const globals = {
|
|
19508
19956
|
...this.globalData,
|
|
19509
19957
|
// return all storefront settings in the store
|
|
@@ -19519,10 +19967,24 @@ var SwellTheme3 = class {
|
|
|
19519
19967
|
geo,
|
|
19520
19968
|
configs,
|
|
19521
19969
|
language: configs?.language,
|
|
19970
|
+
...pageRecord ? getRecordGlobals(this, pageRecord) : {
|
|
19971
|
+
page_title: page.title,
|
|
19972
|
+
page_description: page.description
|
|
19973
|
+
},
|
|
19974
|
+
all_country_option_tags: countryOptions,
|
|
19975
|
+
country_option_tags: countryOptions,
|
|
19522
19976
|
canonical_url: `${store.url}${this.swell.url?.pathname || ""}`,
|
|
19977
|
+
powered_by_link: POWERED_BY_LINK,
|
|
19523
19978
|
// Flag to enable Shopify compatibility in sections and tags/filters
|
|
19524
19979
|
shopify_compatibility: Boolean(settings.shopify_compatibility)
|
|
19525
19980
|
};
|
|
19981
|
+
switch (pageId) {
|
|
19982
|
+
case "robots.txt":
|
|
19983
|
+
globals.robots = getRobotsGlobals(globals.canonical_url);
|
|
19984
|
+
break;
|
|
19985
|
+
default:
|
|
19986
|
+
break;
|
|
19987
|
+
}
|
|
19526
19988
|
if (this.shopifyCompatibility) {
|
|
19527
19989
|
this.shopifyCompatibility.initGlobals(globals);
|
|
19528
19990
|
}
|
|
@@ -19857,7 +20319,7 @@ var SwellTheme3 = class {
|
|
|
19857
20319
|
return languageConfig;
|
|
19858
20320
|
}
|
|
19859
20321
|
const localeShortCode = locale.split("-")[0];
|
|
19860
|
-
return (0,
|
|
20322
|
+
return (0, import_lodash_es13.reduce)(
|
|
19861
20323
|
languageConfig,
|
|
19862
20324
|
(acc, value, key) => {
|
|
19863
20325
|
if (isObject2(value)) {
|
|
@@ -19881,15 +20343,15 @@ var SwellTheme3 = class {
|
|
|
19881
20343
|
const translationEnd = translationParts.pop();
|
|
19882
20344
|
const translationPath = translationParts.join(".");
|
|
19883
20345
|
const translationConfigGlobal = this.globals.language;
|
|
19884
|
-
acc[key] = (0,
|
|
20346
|
+
acc[key] = (0, import_lodash_es13.get)(
|
|
19885
20347
|
translationConfigGlobal,
|
|
19886
20348
|
`${translationPath}.$locale.${locale}.${translationEnd}`
|
|
19887
|
-
) || (0,
|
|
20349
|
+
) || (0, import_lodash_es13.get)(
|
|
19888
20350
|
translationConfigGlobal,
|
|
19889
20351
|
`${translationPath}.$locale.${localeShortCode}.${translationEnd}`
|
|
19890
|
-
) || (0,
|
|
20352
|
+
) || (0, import_lodash_es13.get)(translationConfigGlobal, translationKey) || value;
|
|
19891
20353
|
} else {
|
|
19892
|
-
acc[key] = (0,
|
|
20354
|
+
acc[key] = (0, import_lodash_es13.get)(languageConfig, `$locale.${locale}.${key}`) || (0, import_lodash_es13.get)(languageConfig, `$locale.${localeShortCode}.${key}`) || value;
|
|
19893
20355
|
}
|
|
19894
20356
|
}
|
|
19895
20357
|
return acc;
|
|
@@ -19904,7 +20366,7 @@ var SwellTheme3 = class {
|
|
|
19904
20366
|
}
|
|
19905
20367
|
return this.shopifyCompatibility;
|
|
19906
20368
|
};
|
|
19907
|
-
if (
|
|
20369
|
+
if (Object.keys(configs.editor).length <= 0 && configs.settings_schema) {
|
|
19908
20370
|
const store = await this.swell.storefront.settings.get("store");
|
|
19909
20371
|
configs.editor = shopifyCompatibility().getEditorConfig(
|
|
19910
20372
|
configs.settings_schema
|
|
@@ -19915,13 +20377,13 @@ var SwellTheme3 = class {
|
|
|
19915
20377
|
store.locale || "en-US"
|
|
19916
20378
|
);
|
|
19917
20379
|
}
|
|
19918
|
-
if (
|
|
20380
|
+
if (Object.keys(configs.theme).length <= 0 && configs.settings_data) {
|
|
19919
20381
|
configs.theme = shopifyCompatibility().getThemeConfig(
|
|
19920
20382
|
configs.settings_data
|
|
19921
20383
|
);
|
|
19922
20384
|
this.themeSettingFilePath = "theme/config/settings_data.json";
|
|
19923
20385
|
}
|
|
19924
|
-
if (
|
|
20386
|
+
if (Object.keys(configs.presets).length <= 0 && configs.settings_data) {
|
|
19925
20387
|
configs.presets = shopifyCompatibility().getPresetsConfig(
|
|
19926
20388
|
configs.settings_data
|
|
19927
20389
|
);
|
|
@@ -20113,8 +20575,11 @@ var SwellTheme3 = class {
|
|
|
20113
20575
|
}
|
|
20114
20576
|
return null;
|
|
20115
20577
|
}
|
|
20578
|
+
async getAssetConfig(assetName) {
|
|
20579
|
+
return await this.getThemeConfig(`theme/assets/${assetName}`) ?? await this.getThemeConfig(`assets/${assetName}`) ?? null;
|
|
20580
|
+
}
|
|
20116
20581
|
async getAssetUrl(filePath) {
|
|
20117
|
-
const assetConfig = await this.
|
|
20582
|
+
const assetConfig = await this.getAssetConfig(filePath);
|
|
20118
20583
|
const file = assetConfig?.file;
|
|
20119
20584
|
if (!file) {
|
|
20120
20585
|
return null;
|
|
@@ -20416,13 +20881,42 @@ ${content.slice(pos)}`;
|
|
|
20416
20881
|
}
|
|
20417
20882
|
return "";
|
|
20418
20883
|
}
|
|
20419
|
-
async renderLayout(layoutName, data) {
|
|
20884
|
+
async renderLayout(layoutName, data, contentForLayout, contentForHeader) {
|
|
20420
20885
|
layoutName = layoutName || this.liquidSwell.layoutName;
|
|
20421
20886
|
if (layoutName) {
|
|
20422
|
-
|
|
20887
|
+
if (data) {
|
|
20888
|
+
data = await this.renderDataFields(data, [
|
|
20889
|
+
"page_title",
|
|
20890
|
+
"page_description"
|
|
20891
|
+
]);
|
|
20892
|
+
}
|
|
20893
|
+
return this.renderLayoutTemplate(layoutName, {
|
|
20894
|
+
...data,
|
|
20895
|
+
content_for_layout: contentForLayout,
|
|
20896
|
+
content_for_header: contentForHeader
|
|
20897
|
+
});
|
|
20423
20898
|
} else {
|
|
20424
|
-
return
|
|
20899
|
+
return contentForLayout || "";
|
|
20900
|
+
}
|
|
20901
|
+
}
|
|
20902
|
+
async renderDataFields(data, fields) {
|
|
20903
|
+
const promises = [];
|
|
20904
|
+
for (const key of fields) {
|
|
20905
|
+
if (typeof data[key] === "string") {
|
|
20906
|
+
promises.push(
|
|
20907
|
+
this.renderTemplateString(data[key], data).then((value) => {
|
|
20908
|
+
if (data) {
|
|
20909
|
+
data[key] = value;
|
|
20910
|
+
}
|
|
20911
|
+
})
|
|
20912
|
+
);
|
|
20913
|
+
}
|
|
20425
20914
|
}
|
|
20915
|
+
if (promises.length > 0) {
|
|
20916
|
+
data = { ...data };
|
|
20917
|
+
await Promise.all(promises);
|
|
20918
|
+
}
|
|
20919
|
+
return data;
|
|
20426
20920
|
}
|
|
20427
20921
|
getContentForHeader() {
|
|
20428
20922
|
let content = "\n";
|
|
@@ -20590,8 +21084,10 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
20590
21084
|
const pageLayout = pageSchema.layout || "";
|
|
20591
21085
|
const pageSectionGroups = [];
|
|
20592
21086
|
this.pageSectionGroups = pageSectionGroups;
|
|
20593
|
-
await this.renderLayout(
|
|
20594
|
-
|
|
21087
|
+
await this.renderLayout(
|
|
21088
|
+
pageLayout,
|
|
21089
|
+
{},
|
|
21090
|
+
new RenderDrop(() => {
|
|
20595
21091
|
pageSectionGroups.push({
|
|
20596
21092
|
prop: SECTION_GROUP_CONTENT,
|
|
20597
21093
|
label: "Template",
|
|
@@ -20600,7 +21096,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
20600
21096
|
});
|
|
20601
21097
|
return "";
|
|
20602
21098
|
})
|
|
20603
|
-
|
|
21099
|
+
);
|
|
20604
21100
|
this.pageSectionGroups = null;
|
|
20605
21101
|
return pageSectionGroups;
|
|
20606
21102
|
}
|
|
@@ -20642,7 +21138,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
20642
21138
|
return Promise.all(
|
|
20643
21139
|
sectionConfigs.map(async (sectionConfig, index) => {
|
|
20644
21140
|
const { section, schema } = sectionConfig;
|
|
20645
|
-
const settings = schema?.fields && this.globals ? resolveSectionSettings(this, sectionConfig) : { ...sectionConfig.settings };
|
|
21141
|
+
const settings = schema?.fields && this.globals ? resolveSectionSettings(this, sectionConfig, index) : { ...sectionConfig.settings };
|
|
20646
21142
|
const templateConfig = await this.getThemeTemplateConfigByType(
|
|
20647
21143
|
"sections",
|
|
20648
21144
|
`${section.type}.liquid`
|
|
@@ -20656,7 +21152,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
20656
21152
|
});
|
|
20657
21153
|
if (settings?.section?.custom_css) {
|
|
20658
21154
|
output += `<style>${scopeCustomCSS(
|
|
20659
|
-
settings
|
|
21155
|
+
settings.section.custom_css,
|
|
20660
21156
|
sectionConfig.id
|
|
20661
21157
|
)}</style>`;
|
|
20662
21158
|
}
|
|
@@ -20686,8 +21182,8 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
|
|
|
20686
21182
|
const keyParts = key?.split(".") || [];
|
|
20687
21183
|
const keyName = keyParts.pop() || "";
|
|
20688
21184
|
const keyPath = keyParts.join(".");
|
|
20689
|
-
const langObject = (0,
|
|
20690
|
-
let localeValue = (0,
|
|
21185
|
+
const langObject = (0, import_lodash_es13.get)(langConfig, keyPath);
|
|
21186
|
+
let localeValue = (0, import_lodash_es13.get)(langObject?.[localeCode], keyName) || (0, import_lodash_es13.get)(langObject?.[localeCode.split("-")[0]], keyName) || langObject?.[keyName];
|
|
20691
21187
|
if (data?.count !== void 0 && localeValue?.one) {
|
|
20692
21188
|
localeValue = data.count === 1 ? localeValue.one : localeValue.other;
|
|
20693
21189
|
}
|
|
@@ -20721,7 +21217,7 @@ var PageNotFound = class extends PageError {
|
|
|
20721
21217
|
super(title, status, description);
|
|
20722
21218
|
}
|
|
20723
21219
|
};
|
|
20724
|
-
function resolveSectionSettings(theme, sectionConfig) {
|
|
21220
|
+
function resolveSectionSettings(theme, sectionConfig, index) {
|
|
20725
21221
|
const { settings, schema } = sectionConfig;
|
|
20726
21222
|
if (!schema || !settings?.section?.settings) {
|
|
20727
21223
|
return settings;
|
|
@@ -20752,7 +21248,10 @@ function resolveSectionSettings(theme, sectionConfig) {
|
|
|
20752
21248
|
settings.section.settings,
|
|
20753
21249
|
editorSettings
|
|
20754
21250
|
),
|
|
20755
|
-
blocks
|
|
21251
|
+
blocks,
|
|
21252
|
+
index0: index,
|
|
21253
|
+
index: typeof index === "number" ? index + 1 : void 0,
|
|
21254
|
+
location: getSectionLocation(settings.section.type)
|
|
20756
21255
|
}
|
|
20757
21256
|
};
|
|
20758
21257
|
}
|
|
@@ -20766,7 +21265,7 @@ function fillDefaultThemeSettings(themeSettings, editorSchemaSettings) {
|
|
|
20766
21265
|
}
|
|
20767
21266
|
}
|
|
20768
21267
|
function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
|
|
20769
|
-
const settings = (0,
|
|
21268
|
+
const settings = (0, import_lodash_es13.cloneDeep)(themeSettings);
|
|
20770
21269
|
if (settings.$locale) {
|
|
20771
21270
|
const { locale } = theme.swell.getStorefrontLocalization();
|
|
20772
21271
|
const localeConfig = settings.$locale[locale] || {};
|
|
@@ -20776,16 +21275,16 @@ function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
|
|
|
20776
21275
|
}
|
|
20777
21276
|
}
|
|
20778
21277
|
}
|
|
20779
|
-
(0,
|
|
21278
|
+
(0, import_lodash_es13.each)(settings, (value, key) => {
|
|
20780
21279
|
const setting = (editorSchemaSettings && findEditorSetting(editorSchemaSettings, key)) ?? null;
|
|
20781
21280
|
if (isObject2(value) && !(value instanceof StorefrontResource)) {
|
|
20782
21281
|
switch (setting?.type) {
|
|
20783
21282
|
case "color_scheme_group": {
|
|
20784
|
-
(0,
|
|
21283
|
+
(0, import_lodash_es13.each)(value, (scheme, schemeId) => {
|
|
20785
21284
|
if (isObject2(scheme) && typeof scheme.settings === "object" && scheme.settings) {
|
|
20786
21285
|
const settings2 = scheme.settings;
|
|
20787
|
-
(0,
|
|
20788
|
-
const fieldDef = (0,
|
|
21286
|
+
(0, import_lodash_es13.each)(settings2, (colorValue, colorId) => {
|
|
21287
|
+
const fieldDef = (0, import_lodash_es13.find)(setting.fields, { id: colorId });
|
|
20789
21288
|
if (fieldDef?.type === "color" && colorValue) {
|
|
20790
21289
|
scheme.id = schemeId;
|
|
20791
21290
|
settings2[colorId] = new ThemeColor(colorValue);
|
|
@@ -20836,7 +21335,7 @@ function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
|
|
|
20836
21335
|
}
|
|
20837
21336
|
function findThemeSettingsByType(type, themeSettings, editorSchemaSettings) {
|
|
20838
21337
|
const foundSettings = [];
|
|
20839
|
-
(0,
|
|
21338
|
+
(0, import_lodash_es13.each)(themeSettings, (value, key) => {
|
|
20840
21339
|
if (isObject2(value) && !(value instanceof ThemeFont) && !(value instanceof StorefrontResource)) {
|
|
20841
21340
|
foundSettings.push(
|
|
20842
21341
|
...findThemeSettingsByType(type, value, editorSchemaSettings)
|
|
@@ -21005,7 +21504,7 @@ function isChildItemActive(items) {
|
|
|
21005
21504
|
}
|
|
21006
21505
|
function getMenuItemValueId(value) {
|
|
21007
21506
|
const fallback = typeof value === "string" ? value : "";
|
|
21008
|
-
const slug = (0,
|
|
21507
|
+
const slug = (0, import_lodash_es14.get)(value, "id", (0, import_lodash_es14.get)(value, "slug", fallback)) || "";
|
|
21009
21508
|
return slug;
|
|
21010
21509
|
}
|
|
21011
21510
|
async function getMenuItemUrlAndResource(theme, menuItem) {
|
|
@@ -21386,6 +21885,7 @@ function getResourceQuery(slug, query) {
|
|
|
21386
21885
|
getPage,
|
|
21387
21886
|
getPageSections,
|
|
21388
21887
|
getSectionGroupProp,
|
|
21888
|
+
getSectionLocation,
|
|
21389
21889
|
getSectionSettingsFromProps,
|
|
21390
21890
|
getThemeSettingsFromProps,
|
|
21391
21891
|
isArray,
|